mirror of
https://github.com/acamarata/solar-spa.git
synced 2026-06-30 19:04:28 +00:00
Complete rewrite of the package from plain JavaScript to TypeScript, compiled to dual CJS/ESM via tsup. The NREL SPA C source is recompiled to WASM with Emscripten using SINGLE_FILE base64 inlining, eliminating bundler path-resolution issues. Changes: - Rewrite JS wrapper in TypeScript with full type definitions - Recompile WASM with -O3 -flto, 1MB fixed memory, no filesystem - Add input validation with descriptive error messages - Add spaFormatted() for HH:MM:SS time strings - Add formatTime() utility and init() for eager WASM loading - Add SPA_ZA, SPA_ZA_INC, SPA_ZA_RTS, SPA_ALL function code exports - Dual CJS/ESM output via tsup with proper exports map - Test suite: 68 ESM + 13 CJS assertions - 100-scenario validation suite across 7 categories - GitHub Wiki with 8 documentation pages - CI workflow: Node 20/22/24 matrix, typecheck, pack-check - NREL attribution in LICENSE and README per their license terms - Minimum Node.js 20
64 lines
3.5 KiB
Text
64 lines
3.5 KiB
Text
MIT License
|
|
|
|
Copyright (c) 2023-2026 Aric Camarata
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
|
|
Third-Party Notice: NREL Solar Position Algorithm
|
|
--------------------------------------------------
|
|
|
|
The files src/spa.c and src/spa.h contain the Solar Position Algorithm (SPA)
|
|
developed at the National Renewable Energy Laboratory (NREL). These files are
|
|
subject to their own license terms, reproduced below from the source:
|
|
|
|
Copyright (C) 2008-2011 Alliance for Sustainable Energy, LLC,
|
|
All Rights Reserved
|
|
|
|
The Solar Position Algorithm ("Software") is code in development prepared
|
|
by employees of the Alliance for Sustainable Energy, LLC, (hereinafter the
|
|
"Contractor"), under Contract No. DE-AC36-08GO28308 ("Contract") with the
|
|
U.S. Department of Energy (the "DOE"). The United States Government has
|
|
been granted for itself and others acting on its behalf a paid-up, non-
|
|
exclusive, irrevocable, worldwide license in the Software to reproduce,
|
|
prepare derivative works, and perform publicly and display publicly.
|
|
Beginning five (5) years after the date permission to assert copyright is
|
|
obtained from the DOE, and subject to any subsequent five (5) year
|
|
renewals, the United States Government is granted for itself and others
|
|
acting on its behalf a paid-up, non-exclusive, irrevocable, worldwide
|
|
license in the Software to reproduce, prepare derivative works, distribute
|
|
copies to the public, perform publicly and display publicly, and to permit
|
|
others to do so. If the Contractor ceases to make this computer software
|
|
available, it may be obtained from DOE's Office of Scientific and Technical
|
|
Information's Energy Science and Technology Software Center (ESTSC) at
|
|
P.O. Box 1020, Oak Ridge, TN 37831-1020.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE CONTRACTOR "AS IS" AND ANY EXPRESS OR
|
|
IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
IN NO EVENT SHALL THE CONTRACTOR OR THE U.S. GOVERNMENT BE LIABLE FOR ANY
|
|
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER,
|
|
INCLUDING BUT NOT LIMITED TO CLAIMS ASSOCIATED WITH THE LOSS OF DATA OR
|
|
PROFITS, WHICH MAY RESULT FROM AN ACTION IN CONTRACT, NEGLIGENCE OR OTHER
|
|
TORTIOUS CLAIM THAT ARISES OUT OF OR IN CONNECTION WITH THE ACCESS, USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
Reference: Reda, I., Andreas, A. (2004). "Solar Position Algorithm for
|
|
Solar Radiation Applications." Solar Energy, 76(5), 577-589.
|
|
|
|
Original source: https://midcdmz.nrel.gov/spa/
|