energy-visualization-sankey 1.0.7 โ†’ 1.0.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "energy-visualization-sankey",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A modern TypeScript library for creating interactive Sankey diagrams that visualize energy flows from sources to consumption sectors.",
5
5
  "keywords": [
6
6
  "sankey",
@@ -0,0 +1,147 @@
1
+ #!/bin/bash
2
+
3
+ # Master Validation Script for US Energy Sankey v5
4
+ # Comprehensive validation with real data (1800-2021)
5
+ # Ensures pixel-perfect accuracy during optimization
6
+
7
+ echo "Energy Sankey - Comprehensive Validation"
8
+ echo "================================================="
9
+ echo "Testing with real US energy data: 1800-2021 (222 years)"
10
+ echo ""
11
+
12
+ # Colors for output
13
+ RED='\033[0;31m'
14
+ GREEN='\033[0;32m'
15
+ YELLOW='\033[1;33m'
16
+ BLUE='\033[0;34m'
17
+ NC='\033[0m' # No Color
18
+
19
+ # Track validation results
20
+ NUMERICAL_RESULT=0
21
+ VISUAL_RESULT=0
22
+ PERFORMANCE_RESULT=0
23
+ BUILD_RESULT=0
24
+
25
+ # Function to print status
26
+ print_status() {
27
+ if [ $1 -eq 0 ]; then
28
+ echo -e "${GREEN} $2 PASSED${NC}"
29
+ else
30
+ echo -e "${RED} $2 FAILED${NC}"
31
+ fi
32
+ }
33
+
34
+ # Function to cleanup background processes
35
+ cleanup() {
36
+ echo -e "\n๐Ÿงน Cleaning up..."
37
+ if [ ! -z "$SERVER_PID" ]; then
38
+ kill $SERVER_PID 2>/dev/null
39
+ wait $SERVER_PID 2>/dev/null
40
+ echo " Server stopped"
41
+ fi
42
+ }
43
+
44
+ # Trap to ensure cleanup on exit
45
+ trap cleanup EXIT INT TERM
46
+
47
+ # Step 1: Build the project
48
+ echo -e "${BLUE}Step 1: Building project...${NC}"
49
+ npm run build
50
+ BUILD_RESULT=$?
51
+ print_status $BUILD_RESULT "Build"
52
+
53
+ if [ $BUILD_RESULT -ne 0 ]; then
54
+ echo -e "${RED}Build failed. Cannot proceed with validation.${NC}"
55
+ exit 1
56
+ fi
57
+
58
+ # Verify required build files exist
59
+ echo "๐Ÿ” Verifying build artifacts..."
60
+ if [ ! -f "dist/us-energy-sankey-v5.standalone.esm.js" ]; then
61
+ echo -e "${RED}Required standalone ESM build not found${NC}"
62
+ exit 1
63
+ fi
64
+ if [ ! -f "examples/data/data.json" ]; then
65
+ echo -e "${RED}Required data file not found${NC}"
66
+ exit 1
67
+ fi
68
+ echo -e "${GREEN}All required files present${NC}"
69
+
70
+ # Step 2: Run numerical validation
71
+ echo -e "\n${BLUE}Step 2: Running numerical validation...${NC}"
72
+ echo "Testing mathematical consistency with real data"
73
+ npm run test:numerical
74
+ NUMERICAL_RESULT=$?
75
+ print_status $NUMERICAL_RESULT "Numerical Validation"
76
+
77
+ # Step 3: Start server for visual/performance tests
78
+ echo -e "\n${BLUE}๐ŸŒ Step 3: Starting local server...${NC}"
79
+ npm run serve &
80
+ SERVER_PID=$!
81
+ echo "Server PID: $SERVER_PID"
82
+
83
+ # Wait for server to start
84
+ echo "Waiting for server to start..."
85
+ sleep 3
86
+
87
+ # Check if server is running
88
+ if ! curl -s http://localhost:8080 > /dev/null; then
89
+ echo -e "${RED} Server failed to start${NC}"
90
+ exit 1
91
+ fi
92
+ echo -e "${GREEN} Server running on http://localhost:8080${NC}"
93
+
94
+ # Step 4: Run visual validation
95
+ echo -e "\n${BLUE} Step 4: Running visual validation...${NC}"
96
+ echo "Testing pixel-perfect accuracy across energy eras"
97
+ npm run test:visual
98
+ VISUAL_RESULT=$?
99
+ print_status $VISUAL_RESULT "Visual Validation"
100
+
101
+ # Step 5: Run performance validation
102
+ echo -e "\n${BLUE} Step 5: Running performance validation...${NC}"
103
+ echo "Testing performance with 222 years of real data"
104
+ npm run test:performance
105
+ PERFORMANCE_RESULT=$?
106
+ print_status $PERFORMANCE_RESULT "Performance Validation"
107
+
108
+ # Generate final report
109
+ echo -e "\nVALIDATION SUMMARY"
110
+ echo "===================="
111
+ print_status $BUILD_RESULT "Build"
112
+ print_status $NUMERICAL_RESULT "Numerical Validation (Real Data Calculations)"
113
+ print_status $VISUAL_RESULT "Visual Validation (Pixel-Perfect Screenshots)"
114
+ print_status $PERFORMANCE_RESULT "Performance Validation (Speed & Memory)"
115
+
116
+ # Calculate overall result
117
+ OVERALL_RESULT=$((BUILD_RESULT + NUMERICAL_RESULT + VISUAL_RESULT + PERFORMANCE_RESULT))
118
+
119
+ if [ $OVERALL_RESULT -eq 0 ]; then
120
+ echo -e "\n${GREEN} ALL VALIDATIONS PASSED!${NC}"
121
+ echo -e "${GREEN} Your optimization maintains identical results${NC}"
122
+ echo -e "${GREEN} Ready for production deployment${NC}"
123
+ else
124
+ echo -e "\n${RED} VALIDATION FAILURES DETECTED${NC}"
125
+ echo -e "${RED} Do not proceed with optimization until all tests pass${NC}"
126
+
127
+ # Provide specific guidance
128
+ if [ $NUMERICAL_RESULT -ne 0 ]; then
129
+ echo -e "${YELLOW} Numerical failures: Check mathematical calculations and constants${NC}"
130
+ fi
131
+ if [ $VISUAL_RESULT -ne 0 ]; then
132
+ echo -e "${YELLOW} Visual failures: Check validation/diffs/ for pixel differences${NC}"
133
+ fi
134
+ if [ $PERFORMANCE_RESULT -ne 0 ]; then
135
+ echo -e "${YELLOW} Performance failures: Check if performance thresholds were exceeded${NC}"
136
+ fi
137
+ fi
138
+
139
+ # Show validation artifacts
140
+ echo -e "\n VALIDATION ARTIFACTS"
141
+ echo "======================"
142
+ echo " Numerical test results: Jest output above"
143
+ echo " Visual baselines: validation/baselines/"
144
+ echo " Visual differences: validation/diffs/"
145
+ echo " Performance data: validation/performance/"
146
+
147
+ exit $OVERALL_RESULT