@jjlmoya/utils-performing-arts 1.1.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 (117) hide show
  1. package/.github/workflows/npm-publish.yml +40 -0
  2. package/.gitignore +6 -0
  3. package/.stylelintrc.json +98 -0
  4. package/astro.config.mjs +19 -0
  5. package/eslint.config.js +201 -0
  6. package/package.json +79 -0
  7. package/prompts/create_tool.md +98 -0
  8. package/prompts/i18n/de.md +16 -0
  9. package/prompts/i18n/en.md +16 -0
  10. package/prompts/i18n/es.md +16 -0
  11. package/prompts/i18n/fr.md +16 -0
  12. package/prompts/i18n/id.md +16 -0
  13. package/prompts/i18n/it.md +16 -0
  14. package/prompts/i18n/ja.md +16 -0
  15. package/prompts/i18n/ko.md +16 -0
  16. package/prompts/i18n/nl.md +16 -0
  17. package/prompts/i18n/pl.md +16 -0
  18. package/prompts/i18n/pt.md +16 -0
  19. package/prompts/i18n/ru.md +16 -0
  20. package/prompts/i18n/sv.md +16 -0
  21. package/prompts/i18n/tr.md +16 -0
  22. package/prompts/i18n/zh.md +16 -0
  23. package/prompts/seo.md +58 -0
  24. package/prompts/translations/french.md +33 -0
  25. package/scripts/postinstall.mjs +27 -0
  26. package/src/category/PerformingArtsCategorySEO.astro +9 -0
  27. package/src/category/i18n/de.ts +27 -0
  28. package/src/category/i18n/en.ts +27 -0
  29. package/src/category/i18n/es.ts +27 -0
  30. package/src/category/i18n/fr.ts +27 -0
  31. package/src/category/i18n/id.ts +27 -0
  32. package/src/category/i18n/it.ts +27 -0
  33. package/src/category/i18n/ja.ts +27 -0
  34. package/src/category/i18n/ko.ts +27 -0
  35. package/src/category/i18n/nl.ts +27 -0
  36. package/src/category/i18n/pl.ts +27 -0
  37. package/src/category/i18n/pt.ts +27 -0
  38. package/src/category/i18n/ru.ts +27 -0
  39. package/src/category/i18n/sv.ts +27 -0
  40. package/src/category/i18n/tr.ts +27 -0
  41. package/src/category/i18n/zh.ts +27 -0
  42. package/src/category/index.ts +10 -0
  43. package/src/components/PreviewNavSidebar.astro +116 -0
  44. package/src/components/PreviewToolbar.astro +143 -0
  45. package/src/data.ts +10 -0
  46. package/src/entries.ts +3 -0
  47. package/src/env.d.ts +5 -0
  48. package/src/index.ts +20 -0
  49. package/src/layouts/PreviewLayout.astro +118 -0
  50. package/src/pages/[locale]/[slug].astro +165 -0
  51. package/src/pages/[locale].astro +251 -0
  52. package/src/pages/index.astro +4 -0
  53. package/src/tests/bibliography_wellformed_export.test.ts +46 -0
  54. package/src/tests/category_seo_quality.test.ts +74 -0
  55. package/src/tests/diacritics_density.test.ts +118 -0
  56. package/src/tests/faq_count.test.ts +18 -0
  57. package/src/tests/i18n_coverage.test.ts +34 -0
  58. package/src/tests/inverted_punctuation.test.ts +84 -0
  59. package/src/tests/locale_completeness.test.ts +23 -0
  60. package/src/tests/mocks/astro_mock.js +2 -0
  61. package/src/tests/no_em_dash.test.ts +47 -0
  62. package/src/tests/no_en_dash.test.ts +70 -0
  63. package/src/tests/no_h1_in_components.test.ts +48 -0
  64. package/src/tests/pagespeed_best_practices.test.ts +198 -0
  65. package/src/tests/qa-test-helpers.ts +32 -0
  66. package/src/tests/qa_bibliography_links.test.ts +43 -0
  67. package/src/tests/qa_claim_evidence.test.ts +69 -0
  68. package/src/tests/qa_logic_reference_coverage.test.ts +46 -0
  69. package/src/tests/qa_runtime_i18n.test.ts +100 -0
  70. package/src/tests/schemas_fulfillment.test.ts +23 -0
  71. package/src/tests/script_density.test.ts +94 -0
  72. package/src/tests/seo_length.test.ts +22 -0
  73. package/src/tests/seo_parity.test.ts +60 -0
  74. package/src/tests/seo_translation_completeness.test.ts +69 -0
  75. package/src/tests/seo_wellformed_export.test.ts +65 -0
  76. package/src/tests/shared-test-helpers.ts +56 -0
  77. package/src/tests/slug_language_code_format.test.ts +23 -0
  78. package/src/tests/slug_uniqueness.test.ts +81 -0
  79. package/src/tests/spanish_leakage.test.ts +175 -0
  80. package/src/tests/title_quality.test.ts +55 -0
  81. package/src/tests/tool_exports.test.ts +34 -0
  82. package/src/tests/tool_validation.test.ts +16 -0
  83. package/src/tests/translation_copy.test.ts +115 -0
  84. package/src/tool/rehearsal-call-sheet-planner/bibliography.astro +6 -0
  85. package/src/tool/rehearsal-call-sheet-planner/bibliography.ts +12 -0
  86. package/src/tool/rehearsal-call-sheet-planner/component.astro +74 -0
  87. package/src/tool/rehearsal-call-sheet-planner/controller.ts +98 -0
  88. package/src/tool/rehearsal-call-sheet-planner/dom-views.ts +86 -0
  89. package/src/tool/rehearsal-call-sheet-planner/entry.ts +27 -0
  90. package/src/tool/rehearsal-call-sheet-planner/evaluator.ts +27 -0
  91. package/src/tool/rehearsal-call-sheet-planner/i18n/de.ts +60 -0
  92. package/src/tool/rehearsal-call-sheet-planner/i18n/en.ts +158 -0
  93. package/src/tool/rehearsal-call-sheet-planner/i18n/es.ts +60 -0
  94. package/src/tool/rehearsal-call-sheet-planner/i18n/fr.ts +60 -0
  95. package/src/tool/rehearsal-call-sheet-planner/i18n/id.ts +47 -0
  96. package/src/tool/rehearsal-call-sheet-planner/i18n/it.ts +47 -0
  97. package/src/tool/rehearsal-call-sheet-planner/i18n/ja.ts +47 -0
  98. package/src/tool/rehearsal-call-sheet-planner/i18n/ko.ts +47 -0
  99. package/src/tool/rehearsal-call-sheet-planner/i18n/nl.ts +47 -0
  100. package/src/tool/rehearsal-call-sheet-planner/i18n/pl.ts +47 -0
  101. package/src/tool/rehearsal-call-sheet-planner/i18n/pt.ts +47 -0
  102. package/src/tool/rehearsal-call-sheet-planner/i18n/ru.ts +48 -0
  103. package/src/tool/rehearsal-call-sheet-planner/i18n/sv.ts +48 -0
  104. package/src/tool/rehearsal-call-sheet-planner/i18n/tr.ts +48 -0
  105. package/src/tool/rehearsal-call-sheet-planner/i18n/zh.ts +48 -0
  106. package/src/tool/rehearsal-call-sheet-planner/index.ts +11 -0
  107. package/src/tool/rehearsal-call-sheet-planner/logic.test.ts +68 -0
  108. package/src/tool/rehearsal-call-sheet-planner/logic.ts +229 -0
  109. package/src/tool/rehearsal-call-sheet-planner/rehearsal-call-sheet-planner.css +593 -0
  110. package/src/tool/rehearsal-call-sheet-planner/seo.astro +16 -0
  111. package/src/tool/rehearsal-call-sheet-planner/storage.ts +33 -0
  112. package/src/tool/rehearsal-call-sheet-planner/types.ts +84 -0
  113. package/src/tool/rehearsal-call-sheet-planner/ui.ts +70 -0
  114. package/src/tools.ts +8 -0
  115. package/src/types.ts +68 -0
  116. package/tsconfig.json +15 -0
  117. package/vitest.config.ts +20 -0
@@ -0,0 +1,175 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ALL_ENTRIES } from '../entries';
3
+
4
+ const STRUCTURAL_KEYS = new Set([
5
+ 'id',
6
+ 'slug',
7
+ 'url',
8
+ 'icon',
9
+ 'image',
10
+ 'imageUrl',
11
+ 'keywords',
12
+ 'category',
13
+ 'tags',
14
+ 'toolId',
15
+ 'type',
16
+ 'locale',
17
+ 'language',
18
+ 'direction',
19
+ ]);
20
+
21
+ const TRANSLATABLE_KEYS = [
22
+ 'title',
23
+ 'description',
24
+ 'faqTitle',
25
+ 'faq',
26
+ 'howTo',
27
+ 'seo',
28
+ 'schemas',
29
+ ] as const;
30
+
31
+ const COPY_THRESHOLD = 0.9;
32
+
33
+ const SPANISH_MARKERS = [
34
+ ['sangre', /\bsangre\b/gi],
35
+ ['molino', /\bmolino\b/gi],
36
+ ['grano', /\bgrano\b/gi],
37
+ ['paladar', /\bpaladar\b/gi],
38
+ ['cuchillas', /\bcuchillas\b/gi],
39
+ ['trozos', /\btrozos\b/gi],
40
+ ['frescura', /\bfrescura\b/gi],
41
+ ['ingresa', /\bingresa\b/gi],
42
+ ['selecciona', /\bselecciona\b/gi],
43
+ ['herramienta', /\bherramienta\b/gi],
44
+ ['según', /\bsegún\b/gi],
45
+ ['después', /\bdespués\b/gi],
46
+ ['puedes', /\bpuedes\b/gi],
47
+ ['debes', /\bdebes\b/gi],
48
+ ['tus', /\btus\b/gi],
49
+ ['a la vez', /\ba la vez\b/gi],
50
+ ['los datos', /\blos datos\b/gi],
51
+ ['las opciones', /\blas opciones\b/gi],
52
+ ['el resultado', /\bel resultado\b/gi],
53
+ ['método de extracción', /\bmétodo de extracción\b/gi],
54
+ ['uniformidad del molino', /\buniformidad del molino\b/gi],
55
+ ['café recién tostado', /\bcafé recién tostado\b/gi],
56
+ ] as const;
57
+
58
+ type UnknownRecord = Record<string, unknown>;
59
+
60
+ function normalize(value: string): string {
61
+ return value
62
+ .replace(/<[^>]*>/g, ' ')
63
+ .replace(/&nbsp;/gi, ' ')
64
+ .replace(/\s+/g, ' ')
65
+ .trim()
66
+ .toLocaleLowerCase('es');
67
+ }
68
+
69
+ function isTechnicalInvariant(text: string): boolean {
70
+ const ledUnitMatches = text.match(/\b\d+(?:-\d+)?\s*(?:w|lm)\b/g) ?? [];
71
+ return [
72
+ 'data:image/svg+xml;base64',
73
+ 'background-image: url',
74
+ '.layout-playground {',
75
+ 'const samplerate =',
76
+ ].some((pattern) => text.includes(pattern)) ||
77
+ (text.includes('presets') && text.includes('hz')) ||
78
+ (text.includes('t_rectal') && text.includes('exp(-k * t)')) ||
79
+ (text.includes('led') && ledUnitMatches.length >= 3);
80
+ }
81
+
82
+ function collectString(value: string, output: string[]): void {
83
+ const text = normalize(value);
84
+ if (!isTechnicalInvariant(text) && text.length >= 20) output.push(text);
85
+ }
86
+
87
+ function collectObject(value: UnknownRecord, output: string[]): void {
88
+ Object.entries(value).forEach(([childKey, childValue]) => {
89
+ collectText(childValue, output, childKey);
90
+ });
91
+ }
92
+
93
+ function collectText(value: unknown, output: string[], key?: string): void {
94
+ if (key && STRUCTURAL_KEYS.has(key)) return;
95
+ if (typeof value === 'string') return collectString(value, output);
96
+ if (Array.isArray(value)) return value.forEach((item) => collectText(item, output));
97
+ if (value && typeof value === 'object') collectObject(value as UnknownRecord, output);
98
+ }
99
+
100
+ async function loadText(loader: unknown): Promise<string[]> {
101
+ if (typeof loader !== 'function') return [];
102
+ const module = await (loader as () => Promise<unknown>)();
103
+ const output: string[] = [];
104
+ if (module && typeof module === 'object') {
105
+ const record = module as UnknownRecord;
106
+ for (const key of TRANSLATABLE_KEYS) {
107
+ collectText(record[key], output, key);
108
+ }
109
+ }
110
+ return output;
111
+ }
112
+
113
+ function findSpanishMarkers(text: string[]): string[] {
114
+ const corpus = text.join(' ');
115
+ return SPANISH_MARKERS.flatMap(([label, pattern]) =>
116
+ pattern.test(corpus) ? [label] : [],
117
+ );
118
+ }
119
+
120
+ function similarity(left: string, right: string): number {
121
+ const leftTokens = left.split(/\s+/);
122
+ const rightCounts = new Map<string, number>();
123
+ right.split(/\s+/).forEach((token) => rightCounts.set(token, (rightCounts.get(token) ?? 0) + 1));
124
+ const matches = leftTokens.reduce((total, token) => {
125
+ const count = rightCounts.get(token) ?? 0;
126
+ if (count > 0) rightCounts.set(token, count - 1);
127
+ return total + (count > 0 ? 1 : 0);
128
+ }, 0);
129
+ return (2 * matches) / (leftTokens.length + right.split(/\s+/).length);
130
+ }
131
+
132
+ function findCopiedFragments(spanish: string[], translated: string[]): string[] {
133
+ return spanish
134
+ .filter((fragment) => fragment.length >= 80)
135
+ .filter((fragment) => translated.some((candidate) =>
136
+ candidate.length >= 80 &&
137
+ Math.min(fragment.length, candidate.length) / Math.max(fragment.length, candidate.length) >= COPY_THRESHOLD &&
138
+ similarity(fragment, candidate) >= COPY_THRESHOLD,
139
+ ))
140
+ .sort((a, b) => b.length - a.length)
141
+ .slice(0, 3);
142
+ }
143
+
144
+ describe('Locales must not contain copied Spanish content', () => {
145
+ for (const entry of ALL_ENTRIES) {
146
+ it(`${entry.id} has no untranslated Spanish blocks`, async () => {
147
+ const spanish = await loadText(entry.i18n.es);
148
+ const failures: string[] = [];
149
+
150
+ for (const [locale, loader] of Object.entries(entry.i18n)) {
151
+ if (locale === 'es') continue;
152
+
153
+ const translated = await loadText(loader);
154
+ const copiedFragments = findCopiedFragments(spanish, translated);
155
+ const markerHits = findSpanishMarkers(translated);
156
+
157
+ if (copiedFragments.length > 0 || markerHits.length >= 2) {
158
+ const details = [
159
+ copiedFragments.length > 0
160
+ ? `copied fragments: ${copiedFragments
161
+ .map((fragment) => JSON.stringify(fragment.slice(0, 120)))
162
+ .join(', ')}`
163
+ : '',
164
+ markerHits.length >= 2 ? `Spanish markers: ${markerHits.join(', ')}` : '',
165
+ ]
166
+ .filter(Boolean)
167
+ .join('; ');
168
+ failures.push(`${locale}: ${details}`);
169
+ }
170
+ }
171
+
172
+ expect(failures, failures.join('\n')).toEqual([]);
173
+ });
174
+ }
175
+ });
@@ -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
+ });
@@ -0,0 +1,34 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+ import { validateToolExports } from './shared-test-helpers';
4
+
5
+ describe('Tool Exports Pattern Validation', () => {
6
+ describe('Component Exports Format', () => {
7
+ ALL_TOOLS.forEach((tool) => {
8
+ it(`${tool.entry.id}: Component should be a lazy-loaded function`, () => {
9
+ expect(typeof tool.Component).toBe('function');
10
+ expect(tool.Component).toBeInstanceOf(Function);
11
+ });
12
+
13
+ it(`${tool.entry.id}: SEOComponent should be a lazy-loaded function`, () => {
14
+ expect(typeof tool.SEOComponent).toBe('function');
15
+ expect(tool.SEOComponent).toBeInstanceOf(Function);
16
+ });
17
+
18
+ it(`${tool.entry.id}: BibliographyComponent should be a lazy-loaded function`, () => {
19
+ expect(typeof tool.BibliographyComponent).toBe('function');
20
+ expect(tool.BibliographyComponent).toBeInstanceOf(Function);
21
+ });
22
+ });
23
+ });
24
+
25
+ describe('Dynamic Import Validation', () => {
26
+ it('all tools must have functional dynamic imports', async () => {
27
+ const result = await validateToolExports(ALL_TOOLS);
28
+ if (!result.passed) {
29
+ throw new Error(`Tool export validation failed:\n${result.failures.join('\n')}`);
30
+ }
31
+ expect(result.passed).toBe(true);
32
+ });
33
+ });
34
+ });
@@ -0,0 +1,16 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+ import { performingArtsCategory } from '../data';
4
+
5
+ describe('Tool Validation Suite', () => {
6
+ describe('Library Registration', () => {
7
+ it('should have tools in ALL_TOOLS', () => {
8
+ expect(ALL_TOOLS.length).toBe(1);
9
+ });
10
+
11
+ it('performingArtsCategory should be defined', () => {
12
+ expect(performingArtsCategory).toBeDefined();
13
+ expect(performingArtsCategory.i18n).toBeDefined();
14
+ });
15
+ });
16
+ });
@@ -0,0 +1,115 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ALL_ENTRIES } from '../entries';
3
+
4
+ const COPY_THRESHOLD = 0.9;
5
+
6
+ const STRUCTURAL_KEYS = new Set([
7
+ '@context',
8
+ '@type',
9
+ 'applicationCategory',
10
+ 'columns',
11
+ 'highlight',
12
+ 'icon',
13
+ 'level',
14
+ 'operatingSystem',
15
+ 'position',
16
+ 'positive',
17
+ 'price',
18
+ 'priceCurrency',
19
+ 'slug',
20
+ 'trend',
21
+ 'type',
22
+ 'url',
23
+ 'value',
24
+ 'variant',
25
+ ]);
26
+
27
+ function normalizeText(value: string): string {
28
+ return value
29
+ .replace(/<[^>]*>/g, ' ')
30
+ .replace(/&(?:amp|lt|gt|quot|apos|nbsp);/gi, ' ')
31
+ .replace(/[\u2018\u2019]/g, "'")
32
+ .replace(/[\u201c\u201d]/g, '"')
33
+ .replace(/\s+/g, ' ')
34
+ .trim()
35
+ .toLocaleLowerCase();
36
+ }
37
+
38
+ function collectText(value: unknown, path: string, parts: string[]): void {
39
+ if (typeof value === 'string') {
40
+ const normalized = normalizeText(value);
41
+ if (normalized.length >= 2) parts.push(normalized);
42
+ return;
43
+ }
44
+
45
+ if (Array.isArray(value)) {
46
+ value.forEach((item, index) => collectText(item, `${path}[${index}]`, parts));
47
+ return;
48
+ }
49
+
50
+ if (!value || typeof value !== 'object') return;
51
+
52
+ Object.entries(value).forEach(([key, child]) => {
53
+ if (STRUCTURAL_KEYS.has(key)) return;
54
+ collectText(child, `${path}.${key}`, parts);
55
+ });
56
+ }
57
+
58
+ function localeCorpus(content: unknown): string {
59
+ if (!content || typeof content !== 'object') return '';
60
+
61
+ const record = content as Record<string, unknown>;
62
+ const parts: string[] = [];
63
+ collectText(record.title, 'title', parts);
64
+ collectText(record.description, 'description', parts);
65
+ collectText(record.faqTitle, 'faqTitle', parts);
66
+ collectText(record.faq, 'faq', parts);
67
+ collectText(record.seo, 'seo', parts);
68
+ collectText(record.schemas, 'schemas', parts);
69
+ return parts.join(' ');
70
+ }
71
+
72
+ function tokenCounts(text: string): Map<string, number> {
73
+ const counts = new Map<string, number>();
74
+ for (const token of text.match(/[\p{L}\p{N}]+/gu) ?? []) {
75
+ counts.set(token, (counts.get(token) ?? 0) + 1);
76
+ }
77
+ return counts;
78
+ }
79
+
80
+ function copySimilarity(left: string, right: string): number {
81
+ const leftCounts = tokenCounts(left);
82
+ const rightCounts = tokenCounts(right);
83
+ const leftTotal = [...leftCounts.values()].reduce((sum, count) => sum + count, 0);
84
+ const rightTotal = [...rightCounts.values()].reduce((sum, count) => sum + count, 0);
85
+ if (leftTotal === 0 || rightTotal === 0) return 0;
86
+
87
+ let shared = 0;
88
+ for (const [token, count] of leftCounts) {
89
+ shared += Math.min(count, rightCounts.get(token) ?? 0);
90
+ }
91
+ return (2 * shared) / (leftTotal + rightTotal);
92
+ }
93
+
94
+ function findViolations(corpora: Map<string, string>): string[] {
95
+ const locales = [...corpora.keys()];
96
+ return locales.flatMap((left, leftIndex) => locales.slice(leftIndex + 1).flatMap((right) => {
97
+ const similarity = copySimilarity(corpora.get(left) ?? '', corpora.get(right) ?? '');
98
+ return similarity >= COPY_THRESHOLD ? left + ' ↔ ' + right + ': ' + (similarity * 100).toFixed(1) + '%' : [];
99
+ }));
100
+ }
101
+
102
+ describe('Locales must not copy another locale wholesale', () => {
103
+ ALL_ENTRIES.forEach((entry) => {
104
+ it(`${entry.id} is not at least ${COPY_THRESHOLD * 100}% identical to another locale`, async () => {
105
+ const corpora = new Map<string, string>();
106
+
107
+ for (const [locale, loader] of Object.entries(entry.i18n)) {
108
+ if (!loader) continue;
109
+ corpora.set(locale, localeCorpus(await loader()));
110
+ }
111
+
112
+ expect(findViolations(corpora), `Locale copy threshold exceeded in ${entry.id}`).toEqual([]);
113
+ });
114
+ });
115
+ });
@@ -0,0 +1,6 @@
1
+ ---
2
+ import { Bibliography } from '@jjlmoya/utils-shared';
3
+ import { bibliography } from './bibliography';
4
+ ---
5
+
6
+ <Bibliography links={bibliography} />
@@ -0,0 +1,12 @@
1
+ import type { BibliographyEntry } from '../../types';
2
+
3
+ export const bibliography: BibliographyEntry[] = [
4
+ {
5
+ name: 'Health and Safety Executive. Working time and rest breaks guidance, United Kingdom',
6
+ url: 'https://www.hse.gov.uk/contact/faqs/workingtime.htm',
7
+ },
8
+ {
9
+ name: 'BOE. Estatuto de los Trabajadores, Spain, original Spanish text',
10
+ url: 'https://www.boe.es/buscar/act.php?id=BOE-A-2015-11430',
11
+ },
12
+ ];
@@ -0,0 +1,74 @@
1
+ ---
2
+ import { DEFAULT_SETTINGS } from './logic';
3
+ import type { RehearsalCallSheetUI } from './ui';
4
+
5
+ interface Props {
6
+ ui: RehearsalCallSheetUI;
7
+ }
8
+
9
+ const { ui } = Astro.props as Props;
10
+ ---
11
+
12
+ <div class="call-sheet-planner" data-call-sheet-planner data-ui={JSON.stringify(ui)}>
13
+ <div class="planner-actions">
14
+ <div class="preset-group">
15
+ <span>{ui.presets}</span>
16
+ <button type="button" data-preset="day">{ui.presetDay}</button>
17
+ <button type="button" data-preset="tight">{ui.presetTight}</button>
18
+ <button type="button" data-preset="showcase">{ui.presetShowcase}</button>
19
+ </div>
20
+ <div class="action-group">
21
+ <button type="button" class="secondary-button" data-print>{ui.print}</button>
22
+ <button type="button" class="primary-button" data-export>{ui.exportData}</button>
23
+ </div>
24
+ </div>
25
+ <div class="planner-layout">
26
+ <section class="planner-controls" aria-label={ui.productionSection}>
27
+ <div class="control-block">
28
+ <div class="block-heading"><span>{ui.productionSection}</span><span class="step-number">01</span></div>
29
+ <label for="show-name">{ui.showName}</label>
30
+ <input id="show-name" data-field="showName" type="text" value={DEFAULT_SETTINGS.showName} placeholder={ui.showNamePlaceholder} />
31
+ <label for="rehearsal-date">{ui.date}</label>
32
+ <input id="rehearsal-date" data-field="date" type="date" />
33
+ </div>
34
+ <div class="control-block">
35
+ <div class="block-heading"><span>{ui.timingSection}</span><span class="step-number">02</span></div>
36
+ <div class="field-grid">
37
+ <label for="day-start">{ui.dayStart}<input id="day-start" data-field="dayStart" type="time" value={DEFAULT_SETTINGS.dayStart} /></label>
38
+ <label for="day-end">{ui.dayEnd}<input id="day-end" data-field="dayEnd" type="time" value={DEFAULT_SETTINGS.dayEnd} /></label>
39
+ </div>
40
+ <label for="break-minutes">{ui.breakMinutes}<input id="break-minutes" data-field="breakMinutes" type="number" min="0" max="180" step="5" value={DEFAULT_SETTINGS.breakMinutes} /></label>
41
+ </div>
42
+ <div class="control-block">
43
+ <div class="block-heading"><span>{ui.sceneSection}</span><span class="step-number">03</span></div>
44
+ <label for="scene-list">{ui.scenesLabel}</label>
45
+ <textarea id="scene-list" data-field="scenesText" rows="7">{DEFAULT_SETTINGS.scenesText}</textarea>
46
+ <small>{ui.scenesHint}</small>
47
+ </div>
48
+ <div class="control-block">
49
+ <div class="block-heading"><span>{ui.availabilitySection}</span><span class="step-number">04</span></div>
50
+ <label for="people-availability">{ui.participantAvailability}</label>
51
+ <textarea id="people-availability" data-field="participantAvailabilityText" rows="5">{DEFAULT_SETTINGS.participantAvailabilityText}</textarea>
52
+ <small>{ui.participantHint}</small>
53
+ <label for="room-availability">{ui.roomAvailability}</label>
54
+ <textarea id="room-availability" data-field="roomAvailabilityText" rows="3">{DEFAULT_SETTINGS.roomAvailabilityText}</textarea>
55
+ <small>{ui.roomHint}</small>
56
+ </div>
57
+ <div class="control-block">
58
+ <label for="production-notes">{ui.notes}</label>
59
+ <textarea id="production-notes" data-field="notes" rows="3" placeholder={ui.notesPlaceholder}>{DEFAULT_SETTINGS.notes}</textarea>
60
+ </div>
61
+ <button type="button" class="reset-button" data-reset>{ui.reset}</button>
62
+ </section>
63
+ <section class="planner-result" aria-live="polite" aria-label={ui.resultSection}>
64
+ <div data-result></div>
65
+ </section>
66
+ </div>
67
+ <p class="rules-note">{ui.rulesNote} <a href="https://www.hse.gov.uk/contact/faqs/workingtime.htm" target="_blank" rel="noreferrer">{ui.rulesLinkLabel}</a></p>
68
+ </div>
69
+
70
+ <script>
71
+ import { mountRehearsalCallSheetPlanner } from './controller';
72
+ const root = document.querySelector('[data-call-sheet-planner]');
73
+ if (root) mountRehearsalCallSheetPlanner(root as HTMLElement & { dataset: DOMStringMap });
74
+ </script>
@@ -0,0 +1,98 @@
1
+ import { calculateCallSheet, DEFAULT_SETTINGS } from './logic';
2
+ import { renderResult } from './dom-views';
3
+ import { clearPlannerSettings, readPlannerSettings, writePlannerSettings } from './storage';
4
+ import type { PlannerSettings } from './types';
5
+
6
+ type Root = HTMLElement & { dataset: DOMStringMap };
7
+ type Labels = Record<string, string>;
8
+
9
+ const PRESETS: Record<string, PlannerSettings> = {
10
+ day: DEFAULT_SETTINGS,
11
+ tight: { ...DEFAULT_SETTINGS, showName: 'A Small Room', dayStart: '10:00', dayEnd: '15:00', breakMinutes: 10, scenesText: 'Warm up | 30 | Studio | Alex, Bea | Start together\nScene work | 120 | Studio | Alex, Bea, Chris | Keep the door clear\nNotes pass | 60 | Studio | Bea, Chris | End with notes' },
12
+ showcase: { ...DEFAULT_SETTINGS, showName: 'The Showcase', dayStart: '13:00', dayEnd: '20:00', breakMinutes: 20, scenesText: 'Spacing | 45 | Main stage | Alex, Bea, Chris | Mark entrances\nFull run | 120 | Main stage | Alex, Bea, Chris | No stops\nNotes and reset | 45 | Main stage | Alex, Bea, Chris | Capture changes', participantAvailabilityText: 'Alex | 13:00-20:00\nBea | 13:00-20:00\nChris | 13:00-20:00', roomAvailabilityText: 'Main stage | 13:00-20:00' },
13
+ };
14
+
15
+ function getUi(root: Root): Labels {
16
+ try {
17
+ return JSON.parse(root.dataset.ui ?? '{}') as Labels;
18
+ } catch {
19
+ return {};
20
+ }
21
+ }
22
+
23
+ function getField<T extends HTMLInputElement | HTMLTextAreaElement>(root: Root, key: string): T {
24
+ return root.querySelector(`[data-field="${key}"]`) as T;
25
+ }
26
+
27
+ function getSettings(root: Root): PlannerSettings {
28
+ return {
29
+ showName: getField(root, 'showName').value,
30
+ date: getField(root, 'date').value,
31
+ dayStart: getField(root, 'dayStart').value,
32
+ dayEnd: getField(root, 'dayEnd').value,
33
+ breakMinutes: Number(getField(root, 'breakMinutes').value),
34
+ scenesText: getField(root, 'scenesText').value,
35
+ participantAvailabilityText: getField(root, 'participantAvailabilityText').value,
36
+ roomAvailabilityText: getField(root, 'roomAvailabilityText').value,
37
+ notes: getField(root, 'notes').value,
38
+ };
39
+ }
40
+
41
+ function setSettings(root: Root, settings: PlannerSettings): void {
42
+ Object.entries(settings).forEach(([key, value]) => {
43
+ const field = getField(root, key);
44
+ if (field) field.value = String(value);
45
+ });
46
+ }
47
+
48
+ function render(root: Root): void {
49
+ const result = calculateCallSheet(getSettings(root));
50
+ queryResult(root).innerHTML = renderResult(result, getUi(root));
51
+ writePlannerSettings(result.settings);
52
+ root.dataset.status = result.conflictCount + result.unscheduledCount > 0 ? 'attention' : 'ready';
53
+ }
54
+
55
+ function queryResult(root: Root): HTMLElement {
56
+ return root.querySelector('[data-result]') as HTMLElement;
57
+ }
58
+
59
+ function downloadResult(root: Root): void {
60
+ const result = calculateCallSheet(getSettings(root));
61
+ const blob = new Blob([JSON.stringify(result, null, 2)], { type: 'application/json' });
62
+ const url = URL.createObjectURL(blob);
63
+ const link = document.createElement('a');
64
+ link.href = url;
65
+ link.download = `${(result.settings.showName || 'rehearsal-call-sheet').toLocaleLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'rehearsal-call-sheet'}.json`;
66
+ document.body.appendChild(link);
67
+ link.click();
68
+ link.remove();
69
+ window.setTimeout(() => URL.revokeObjectURL(url), 1000);
70
+ }
71
+
72
+ function bindFields(root: Root): void {
73
+ root.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>('[data-field]').forEach((field) => {
74
+ field.addEventListener('input', () => render(root));
75
+ field.addEventListener('change', () => render(root));
76
+ });
77
+ }
78
+
79
+ function bindButtons(root: Root): void {
80
+ root.querySelectorAll<HTMLButtonElement>('[data-preset]').forEach((button) => button.addEventListener('click', () => {
81
+ setSettings(root, PRESETS[button.dataset.preset ?? ''] ?? DEFAULT_SETTINGS);
82
+ render(root);
83
+ }));
84
+ root.querySelector('[data-export]')?.addEventListener('click', () => downloadResult(root));
85
+ root.querySelector('[data-print]')?.addEventListener('click', () => window.print());
86
+ root.querySelector('[data-reset]')?.addEventListener('click', () => {
87
+ clearPlannerSettings();
88
+ setSettings(root, DEFAULT_SETTINGS);
89
+ render(root);
90
+ });
91
+ }
92
+
93
+ export function mountRehearsalCallSheetPlanner(root: Root): void {
94
+ setSettings(root, readPlannerSettings() ?? DEFAULT_SETTINGS);
95
+ bindFields(root);
96
+ bindButtons(root);
97
+ render(root);
98
+ }