gbu-accessibility-package 3.8.0 → 3.8.2

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/example.js DELETED
@@ -1,121 +0,0 @@
1
- /**
2
- * Example usage of Accessibility Fixer
3
- * Demonstrates different ways to use the tool
4
- */
5
-
6
- const AccessibilityFixer = require('./lib/fixer.js');
7
- const chalk = require('chalk');
8
-
9
- async function example1_BasicUsage() {
10
- console.log(chalk.blue('\nšŸ“ Example 1: Basic Usage'));
11
-
12
- const fixer = new AccessibilityFixer({
13
- language: 'ja',
14
- backupFiles: true,
15
- dryRun: true // Preview mode
16
- });
17
-
18
- // Fix all accessibility issues
19
- await fixer.fixHtmlLang('./demo');
20
- await fixer.fixEmptyAltAttributes('./demo');
21
- await fixer.fixRoleAttributes('./demo');
22
- }
23
-
24
- async function example2_EnglishProject() {
25
- console.log(chalk.blue('\nšŸ“ Example 2: English Project'));
26
-
27
- const fixer = new AccessibilityFixer({
28
- language: 'en',
29
- backupFiles: false,
30
- dryRun: false
31
- });
32
-
33
- const results = await fixer.fixRoleAttributes('./demo');
34
- console.log(`Fixed ${results.filter(r => r.status === 'fixed').length} files`);
35
- }
36
-
37
- async function example3_StepByStep() {
38
- console.log(chalk.blue('\nšŸ“ Example 3: Step by Step'));
39
-
40
- const fixer = new AccessibilityFixer({
41
- language: 'vi',
42
- backupFiles: true,
43
- dryRun: false
44
- });
45
-
46
- // Step 1: Fix lang attributes first
47
- console.log('Step 1: Lang attributes...');
48
- await fixer.fixHtmlLang('./demo');
49
-
50
- // Step 2: Fix alt attributes
51
- console.log('Step 2: Alt attributes...');
52
- await fixer.fixEmptyAltAttributes('./demo');
53
-
54
- // Step 3: Fix role attributes
55
- console.log('Step 3: Role attributes...');
56
- await fixer.fixRoleAttributes('./demo');
57
-
58
- console.log('āœ… All done!');
59
- }
60
-
61
- async function example4_CustomConfig() {
62
- console.log(chalk.blue('\nšŸ“ Example 4: Custom Configuration'));
63
-
64
- // Custom configuration for specific needs
65
- const fixer = new AccessibilityFixer({
66
- language: 'zh',
67
- backupFiles: true,
68
- dryRun: true
69
- });
70
-
71
- // Only fix specific issues
72
- const altResults = await fixer.fixEmptyAltAttributes('./demo');
73
-
74
- // Analyze results
75
- const fixedFiles = altResults.filter(r => r.status === 'fixed');
76
- const totalIssues = altResults.reduce((sum, r) => sum + (r.issues || 0), 0);
77
-
78
- console.log(`Found ${totalIssues} alt attribute issues in ${fixedFiles.length} files`);
79
- }
80
-
81
- async function example5_ErrorHandling() {
82
- console.log(chalk.blue('\nšŸ“ Example 5: Error Handling'));
83
-
84
- const fixer = new AccessibilityFixer({
85
- language: 'ja',
86
- backupFiles: true,
87
- dryRun: false
88
- });
89
-
90
- try {
91
- const results = await fixer.fixRoleAttributes('./nonexistent-directory');
92
- console.log('Results:', results);
93
- } catch (error) {
94
- console.error(chalk.red('Error occurred:'), error.message);
95
- // Handle error appropriately
96
- }
97
- }
98
-
99
- // Run examples
100
- async function runExamples() {
101
- console.log(chalk.green('šŸš€ Accessibility Fixer Examples\n'));
102
-
103
- await example1_BasicUsage();
104
- await example2_EnglishProject();
105
- await example3_StepByStep();
106
- await example4_CustomConfig();
107
- await example5_ErrorHandling();
108
-
109
- console.log(chalk.green('\nāœ… All examples completed!'));
110
- }
111
-
112
- // Uncomment to run examples
113
- // runExamples();
114
-
115
- module.exports = {
116
- example1_BasicUsage,
117
- example2_EnglishProject,
118
- example3_StepByStep,
119
- example4_CustomConfig,
120
- example5_ErrorHandling
121
- };