diff --git a/.gitignore b/.gitignore index 3928069..c8f3c06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .idea .vscode coverage -commonjs +/commonjs/ lib node_modules *.log diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..7308705 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,15 @@ +# How to use Examples + +Run the examples using tsx as below: + +## Typescript + +npx tsx ./examples/typescript/satellite-js-migration.ts + +## ES5 Module + +npx tsx ./examples/es5/satellite-js-migration.mjs + +## CommonJs + +node ./examples/commonjs/satellite-js-migration.cjs diff --git a/examples/commonjs/README.md b/examples/commonjs/README.md deleted file mode 100644 index b9d9208..0000000 --- a/examples/commonjs/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Run the examples using node. - -Example: node ./examples/commonjs/satellite-js-migration.js diff --git a/examples/commonjs/satellite-js-migration.js b/examples/commonjs/satellite-js-migration.cjs similarity index 91% rename from examples/commonjs/satellite-js-migration.js rename to examples/commonjs/satellite-js-migration.cjs index f85218e..a751ca4 100644 --- a/examples/commonjs/satellite-js-migration.js +++ b/examples/commonjs/satellite-js-migration.cjs @@ -1,3 +1,8 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable multiline-comment-style */ +/* eslint-disable no-console */ + const { Satellite, Sgp4, GroundPosition, calcGmst, DEG2RAD } = require('../../commonjs/index.js'); // Example Date @@ -27,7 +32,7 @@ positionAndVelocity = satellite.eci(); const positionEci = positionAndVelocity.position; const velocityEci = positionAndVelocity.velocity; -// Set the Observer at 122.03 West by 36.96 North, in DEGREES (because who likes working in radians?) +// Set the Observer at 71°W, 41°N, 0.37 km altitude using DEGREES because who likes using Radians? const observer = new GroundPosition({ lon: -71.0308, lat: 41.9613422, @@ -38,7 +43,7 @@ const observer = new GroundPosition({ const { gmst, j } = calcGmst(new Date()); // You can get ECF, Geodetic, Look Angles, and Doppler Factor. -const positionEcf = satellite.ecf(); +const positionEcf = satellite.ecf(exampleDate); const observerEcf = observer.ecf(); const positionGd = satellite.lla(exampleDate); const lookAngles = satellite.rae(observer, exampleDate); @@ -46,6 +51,7 @@ const lookAngles = satellite.rae(observer, exampleDate); const uplinkFreq = 420e6; const dopplerFactor = satellite.dopplerFactor(observer, exampleDate); let dopplerShiftedFrequency = uplinkFreq * dopplerFactor; + dopplerShiftedFrequency = satellite.applyDoppler(uplinkFreq, observer, exampleDate); // The coordinates are all stored in strongly typed key-value pairs. @@ -100,6 +106,6 @@ console.log(' rangeSat: ', rangeSat); console.log(' rangeRate: ', rangeRate); console.log('Doppler Factor:'); console.log(' dopplerFactor: ', dopplerFactor); -dopplerShiftedFrequency = dopplerShiftedFrequency / 1e6; // Hz to MHz +dopplerShiftedFrequency /= 1e6; // Hz to MHz console.log(' 420MHz: ', `${dopplerShiftedFrequency.toPrecision(6)} MHz`); console.log('======================================'); diff --git a/examples/mjs/satellite-js-migration.mjs b/examples/es5/satellite-js-migration.mjs similarity index 90% rename from examples/mjs/satellite-js-migration.mjs rename to examples/es5/satellite-js-migration.mjs index 60082ce..c630537 100644 --- a/examples/mjs/satellite-js-migration.mjs +++ b/examples/es5/satellite-js-migration.mjs @@ -1,4 +1,9 @@ -import { calcGmst, GroundPosition, Satellite, Sgp4 } from '../../lib/index.mjs'; +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/no-var-requires */ +/* eslint-disable multiline-comment-style */ +/* eslint-disable no-console */ + +import { calcGmst, DEG2RAD, GroundPosition, Satellite, Sgp4 } from '../../lib/index.js'; // Example Date const exampleDate = new Date(1705109326817); @@ -27,7 +32,7 @@ positionAndVelocity = satellite.eci(); const positionEci = positionAndVelocity.position; const velocityEci = positionAndVelocity.velocity; -// Set the Observer at 122.03 West by 36.96 North, in DEGREES (because who likes working in radians?) +// Set the Observer at 71°W, 41°N, 0.37 km altitude using DEGREES because who likes using Radians? const observer = new GroundPosition({ lon: -71.0308, lat: 41.9613422, @@ -46,6 +51,7 @@ const lookAngles = satellite.rae(observer, exampleDate); const uplinkFreq = 420e6; const dopplerFactor = satellite.dopplerFactor(observer, exampleDate); let dopplerShiftedFrequency = uplinkFreq * dopplerFactor; + dopplerShiftedFrequency = satellite.applyDoppler(uplinkFreq, observer, exampleDate); // The coordinates are all stored in strongly typed key-value pairs. @@ -100,6 +106,6 @@ console.log(' rangeSat: ', rangeSat); console.log(' rangeRate: ', rangeRate); console.log('Doppler Factor:'); console.log(' dopplerFactor: ', dopplerFactor); -dopplerShiftedFrequency = dopplerShiftedFrequency / 1e6; // Hz to MHz +dopplerShiftedFrequency /= 1e6; // Hz to MHz console.log(' 420MHz: ', `${dopplerShiftedFrequency.toPrecision(6)} MHz`); console.log('======================================'); diff --git a/examples/mjs/README.md b/examples/mjs/README.md deleted file mode 100644 index cb81c7b..0000000 --- a/examples/mjs/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Run the examples using tsx. - -Example: npx tsx ./examples/satellite.mjs diff --git a/examples/typescript/README.md b/examples/typescript/README.md deleted file mode 100644 index 9ceabdd..0000000 --- a/examples/typescript/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Run the examples using ts-node. - -Example: npx ts-node ./examples/julian.ts -p ./examples/tsconfig.json diff --git a/examples/typescript/satellite-js-migration.ts b/examples/typescript/satellite-js-migration.ts index 72a5ab3..6647c20 100644 --- a/examples/typescript/satellite-js-migration.ts +++ b/examples/typescript/satellite-js-migration.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /* eslint-disable max-len */ /* eslint-disable @typescript-eslint/no-unused-vars */ import { @@ -12,11 +13,14 @@ import { Sgp4, TleLine1, TleLine2, -} from '../../src/index'; +} from '../../lib/index'; + +// Example Date +const exampleDate = new Date(1705109326817); // Sample TLE -const tle1 = '1 25544U 98067A 19156.50900463 .00003075 00000-0 59442-4 0 9992' as TleLine1; -const tle2 = '2 25544 51.6433 59.2583 0008217 16.4489 347.6017 15.51174618173442' as TleLine2; +const tle1 = '1 56006U 23042W 24012.45049317 .00000296 00000-0 36967-4 0 9992' as TleLine1; +const tle2 = '2 56006 43.0043 13.3620 0001137 267.5965 92.4747 15.02542972 44491' as TleLine2; // Initialize a Satellite Object const satellite = new Satellite({ @@ -47,10 +51,10 @@ const velocityEci = positionAndVelocity.velocity; // typescript will error on th */ const positionEci2 = satellite.eci().position; // This is correctly typed -// Set the Observer at 122.03 West by 36.96 North, in DEGREES (because who likes working in radians?) +// Set the Observer at 71°W, 41°N, 0.37 km altitude using DEGREES because who likes using Radians? const observer = new GroundPosition({ - lon: -122.0308 as Degrees, - lat: 36.9613422 as Degrees, + lon: -71.0308 as Degrees, + lat: 41.9613422 as Degrees, alt: 0.37 as Kilometers, }); @@ -60,12 +64,16 @@ const observer = new GroundPosition({ const { gmst, j } = calcGmst(new Date()); // You can get ECF, Geodetic, Look Angles, and Doppler Factor. -const positionEcf = satellite.ecf(); +const positionEcf = satellite.ecf(exampleDate); const observerEcf = observer.ecf(); -const positionGd = satellite.lla(); -const lookAngles = satellite.rae(observer); +const positionGd = satellite.lla(exampleDate); +const lookAngles = satellite.rae(observer, exampleDate); // This never worked in satellite.js, but it does now! -const dopplerFactor = satellite.dopplerFactor(observer); +const uplinkFreq = 420e6; +const dopplerFactor = satellite.dopplerFactor(observer, exampleDate); +let dopplerShiftedFrequency = uplinkFreq * dopplerFactor; + +dopplerShiftedFrequency = satellite.applyDoppler(uplinkFreq, observer, exampleDate); /** * The coordinates are all stored in strongly typed key-value pairs. @@ -73,17 +81,18 @@ const dopplerFactor = satellite.dopplerFactor(observer); * * satellite.js generates Property 'x' does not exist on type 'boolean | { x: number; y: number; z: number; }'. */ -const position = satellite.eci().position; +const position = satellite.eci(exampleDate).position; const satelliteX = position.x; // This is typed as Kilometers const satelliteY = position.y; // to prevent you from accidentally const satelliteZ = position.z; // mixing Meters with Kilometers. // Look Angles may be accessed by `azimuth`, `elevation`, `range` properties. const azimuth = lookAngles.azimuth; // Typed as Radians -const azimuthDegress = lookAngles.azimuthDegrees; // Typed as Degrees +const azimuthDegrees = lookAngles.azimuthDegrees; // Typed as Degrees const elevation = lookAngles.elevation; // Typed as Radains const elevationDegrees = lookAngles.elevationDegrees; // Typed as Degrees const rangeSat = lookAngles.range; // Typed as Kilometers +const rangeRate = lookAngles.rangeRate; // Kilometers/Second // Geodetic coords are accessed via `longitude`, `latitude`, `height`. const longitude = positionGd.lon; // Longitude is in Degrees @@ -103,25 +112,30 @@ const latitudeRad2 = (latitude * DEG2RAD) as Radians; // lla2eci(positionGd, gmst); // Throws an error: Argument of type 'LlaVec3' is not assignable to parameter of type 'LlaVec3'. lla2eci(observer.llaRad(), gmst); // This is correctly typed -// eslint-disable-next-line no-console -console.log( - positionEci2, - positionEcf, - observerEcf, - positionGd, - lookAngles, - dopplerFactor, - satelliteX, - satelliteY, - satelliteZ, - azimuth, - elevation, - rangeSat, - longitude, - latitude, - height, - longitudeRad, - latitudeRad, - longitudeRad2, - latitudeRad2, -); +console.log('Satellite.js Migration Example'); +console.log('======================================'); +console.log('TLE: ', tle1); +console.log(' ', tle2); +console.log('======================================'); +console.log('Position (ECI):'); +console.log(' x: ', satelliteX); +console.log(' y: ', satelliteY); +console.log(' z: ', satelliteZ); +console.log('Position (ECF):'); +console.log(' x: ', positionEcf.x); +console.log(' y: ', positionEcf.y); +console.log(' z: ', positionEcf.z); +console.log('Position (Geodetic):'); +console.log(' longitude: ', longitude); +console.log(' latitude: ', latitude); +console.log(' height: ', height); +console.log('Look Angles:'); +console.log(' azimuth: ', azimuthDegrees); +console.log(' elevation: ', elevationDegrees); +console.log(' rangeSat: ', rangeSat); +console.log(' rangeRate: ', rangeRate); +console.log('Doppler Factor:'); +console.log(' dopplerFactor: ', dopplerFactor); +dopplerShiftedFrequency /= 1e6; // Hz to MHz +console.log(' 420MHz: ', `${dopplerShiftedFrequency.toPrecision(6)} MHz`); +console.log('======================================'); diff --git a/examples/typescript/tsconfig.json b/examples/typescript/tsconfig.json deleted file mode 100644 index d337c15..0000000 --- a/examples/typescript/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "ES2015", - "baseUrl": "../" - } -} diff --git a/package-lock.json b/package-lock.json index b87ccbb..460aff7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,8 +23,8 @@ "jest": "^28.1.3", "prettier": "^2.8.8", "prettier-plugin-organize-imports": "^3.2.3", - "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", + "tsx": "^4.7.0", "ttypescript": "^1.5.15", "typescript": "^4.9.5", "typescript-transform-paths": "^3.4.6" @@ -1861,6 +1861,7 @@ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, + "peer": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -1873,11 +1874,380 @@ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, + "peer": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.11.tgz", + "integrity": "sha512-FnzU0LyE3ySQk7UntJO4+qIiQgI7KoODnZg5xzXIrFJlKd2P2gwHsHY4927xj9y5PJmJSzULiUCWmv7iWnNa7g==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.11.tgz", + "integrity": "sha512-5OVapq0ClabvKvQ58Bws8+wkLCV+Rxg7tUVbo9xu034Nm536QTII4YzhaFriQ7rMrorfnFKUsArD2lqKbFY4vw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.11.tgz", + "integrity": "sha512-aiu7K/5JnLj//KOnOfEZ0D90obUkRzDMyqd/wNAUQ34m4YUPVhRZpnqKV9uqDGxT7cToSDnIHsGooyIczu9T+Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.11.tgz", + "integrity": "sha512-eccxjlfGw43WYoY9QgB82SgGgDbibcqyDTlk3l3C0jOVHKxrjdc9CTwDUQd0vkvYg5um0OH+GpxYvp39r+IPOg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.11.tgz", + "integrity": "sha512-ETp87DRWuSt9KdDVkqSoKoLFHYTrkyz2+65fj9nfXsaV3bMhTCjtQfw3y+um88vGRKRiF7erPrh/ZuIdLUIVxQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.11.tgz", + "integrity": "sha512-fkFUiS6IUK9WYUO/+22omwetaSNl5/A8giXvQlcinLIjVkxwTLSktbF5f/kJMftM2MJp9+fXqZ5ezS7+SALp4g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.11.tgz", + "integrity": "sha512-lhoSp5K6bxKRNdXUtHoNc5HhbXVCS8V0iZmDvyWvYq9S5WSfTIHU2UGjcGt7UeS6iEYp9eeymIl5mJBn0yiuxA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.11.tgz", + "integrity": "sha512-JkUqn44AffGXitVI6/AbQdoYAq0TEullFdqcMY/PCUZ36xJ9ZJRtQabzMA+Vi7r78+25ZIBosLTOKnUXBSi1Kw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.11.tgz", + "integrity": "sha512-3CRkr9+vCV2XJbjwgzjPtO8T0SZUmRZla+UL1jw+XqHZPkPgZiyWvbDvl9rqAN8Zl7qJF0O/9ycMtjU67HN9/Q==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.11.tgz", + "integrity": "sha512-LneLg3ypEeveBSMuoa0kwMpCGmpu8XQUh+mL8XXwoYZ6Be2qBnVtcDI5azSvh7vioMDhoJFZzp9GWp9IWpYoUg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.11.tgz", + "integrity": "sha512-caHy++CsD8Bgq2V5CodbJjFPEiDPq8JJmBdeyZ8GWVQMjRD0sU548nNdwPNvKjVpamYYVL40AORekgfIubwHoA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.11.tgz", + "integrity": "sha512-ppZSSLVpPrwHccvC6nQVZaSHlFsvCQyjnvirnVjbKSHuE5N24Yl8F3UwYUUR1UEPaFObGD2tSvVKbvR+uT1Nrg==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.11.tgz", + "integrity": "sha512-B5x9j0OgjG+v1dF2DkH34lr+7Gmv0kzX6/V0afF41FkPMMqaQ77pH7CrhWeR22aEeHKaeZVtZ6yFwlxOKPVFyg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.11.tgz", + "integrity": "sha512-MHrZYLeCG8vXblMetWyttkdVRjQlQUb/oMgBNurVEnhj4YWOr4G5lmBfZjHYQHHN0g6yDmCAQRR8MUHldvvRDA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.11.tgz", + "integrity": "sha512-f3DY++t94uVg141dozDu4CCUkYW+09rWtaWfnb3bqe4w5NqmZd6nPVBm+qbz7WaHZCoqXqHz5p6CM6qv3qnSSQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.11.tgz", + "integrity": "sha512-A5xdUoyWJHMMlcSMcPGVLzYzpcY8QP1RtYzX5/bS4dvjBGVxdhuiYyFwp7z74ocV7WDc0n1harxmpq2ePOjI0Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.11.tgz", + "integrity": "sha512-grbyMlVCvJSfxFQUndw5mCtWs5LO1gUlwP4CDi4iJBbVpZcqLVT29FxgGuBJGSzyOxotFG4LoO5X+M1350zmPA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.11.tgz", + "integrity": "sha512-13jvrQZJc3P230OhU8xgwUnDeuC/9egsjTkXN49b3GcS5BKvJqZn86aGM8W9pd14Kd+u7HuFBMVtrNGhh6fHEQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.11.tgz", + "integrity": "sha512-ysyOGZuTp6SNKPE11INDUeFVVQFrhcNDVUgSQVDzqsqX38DjhPEPATpid04LCoUr2WXhQTEZ8ct/EgJCUDpyNw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.11.tgz", + "integrity": "sha512-Hf+Sad9nVwvtxy4DXCZQqLpgmRTQqyFyhT3bZ4F2XlJCjxGmRFF0Shwn9rzhOYRB61w9VMXUkxlBy56dk9JJiQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.11.tgz", + "integrity": "sha512-0P58Sbi0LctOMOQbpEOvOL44Ne0sqbS0XWHMvvrg6NE5jQ1xguCSSw9jQeUk2lfrXYsKDdOe6K+oZiwKPilYPQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.11.tgz", + "integrity": "sha512-6YOrWS+sDJDmshdBIQU+Uoyh7pQKrdykdefC1avn76ss5c+RN6gut3LZA4E2cH5xUEp5/cA0+YxRaVtRAb0xBg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.11.tgz", + "integrity": "sha512-vfkhltrjCAb603XaFhqhAF4LGDi2M4OrCRrFusyQ+iTLQ/o60QQXxc9cZC/FFpihBI9N1Grn6SMKVJ4KP7Fuiw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@eslint/eslintrc": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", @@ -2759,25 +3129,29 @@ "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/@types/babel__core": { "version": "7.20.1", @@ -3416,6 +3790,7 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", "dev": true, + "peer": true, "engines": { "node": ">=0.4.0" } @@ -3507,7 +3882,8 @@ "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true + "dev": true, + "peer": true }, "node_modules/argparse": { "version": "1.0.10", @@ -4074,7 +4450,8 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/cross-spawn": { "version": "7.0.3", @@ -4142,6 +4519,7 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true, + "peer": true, "engines": { "node": ">=0.3.1" } @@ -4254,6 +4632,44 @@ "dev": true, "peer": true }, + "node_modules/esbuild": { + "version": "0.19.11", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.11.tgz", + "integrity": "sha512-HJ96Hev2hX/6i5cDVwcqiJBBtuo9+FeIJOtZ9W1kA5M6AMJRHUZlpYZ1/SbEwtO0ioNAW8rUooVpC/WehY2SfA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.19.11", + "@esbuild/android-arm": "0.19.11", + "@esbuild/android-arm64": "0.19.11", + "@esbuild/android-x64": "0.19.11", + "@esbuild/darwin-arm64": "0.19.11", + "@esbuild/darwin-x64": "0.19.11", + "@esbuild/freebsd-arm64": "0.19.11", + "@esbuild/freebsd-x64": "0.19.11", + "@esbuild/linux-arm": "0.19.11", + "@esbuild/linux-arm64": "0.19.11", + "@esbuild/linux-ia32": "0.19.11", + "@esbuild/linux-loong64": "0.19.11", + "@esbuild/linux-mips64el": "0.19.11", + "@esbuild/linux-ppc64": "0.19.11", + "@esbuild/linux-riscv64": "0.19.11", + "@esbuild/linux-s390x": "0.19.11", + "@esbuild/linux-x64": "0.19.11", + "@esbuild/netbsd-x64": "0.19.11", + "@esbuild/openbsd-x64": "0.19.11", + "@esbuild/sunos-x64": "0.19.11", + "@esbuild/win32-arm64": "0.19.11", + "@esbuild/win32-ia32": "0.19.11", + "@esbuild/win32-x64": "0.19.11" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -4840,6 +5256,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/get-tsconfig": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.2.tgz", + "integrity": "sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -7153,7 +7581,8 @@ "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/makeerror": { "version": "1.0.12", @@ -7807,6 +8236,15 @@ "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/resolve.exports": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-1.1.1.tgz", @@ -8372,6 +8810,7 @@ "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, + "peer": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -8415,6 +8854,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -8466,6 +8906,25 @@ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" } }, + "node_modules/tsx": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.7.0.tgz", + "integrity": "sha512-I+t79RYPlEYlHn9a+KzwrvEwhJg35h/1zHsLC2JXvhC2mdynMv6Zxzvhv5EMV6VF5qJlLlkSnMVvdZV3PSIGcg==", + "dev": true, + "dependencies": { + "esbuild": "~0.19.10", + "get-tsconfig": "^4.7.2" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, "node_modules/ttypescript": { "version": "1.5.15", "resolved": "https://registry.npmjs.org/ttypescript/-/ttypescript-1.5.15.tgz", @@ -8643,7 +9102,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true + "dev": true, + "peer": true }, "node_modules/v8-to-istanbul": { "version": "9.1.0", @@ -8928,6 +9388,7 @@ "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true, + "peer": true, "engines": { "node": ">=6" } diff --git a/package.json b/package.json index e9ba455..05f2a8b 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "ootk-core", "version": "1.0.0-1", + "type": "module", "description": "Orbital Object Toolkit. A modern typed replacement for satellite.js including SGP4 propagation, TLE parsing, Sun and Moon calculations, and more.", "scripts": { - "mjs": "ttsc -p tsconfig.build.json -m esnext && node ./scripts/makeMjs.mjs", + "js": "ttsc -p tsconfig.build.json -m esnext", "cjs": "ttsc -p tsconfig.c.json -m commonjs", - "build": "node ./scripts/cleanup.mjs && npm run mjs && npm run cjs", + "build": "node ./scripts/cleanup.mjs && npm run js && npm run cjs && node ./scripts/makeMjs.mjs", "lint": "eslint src", "lint:fix": "eslint src --fix", "lint:test": "eslint test", @@ -24,11 +25,13 @@ "url": "git://github.com/thkruz/ootk-core" }, "keywords": [ + "satellite", "sgp4", + "sun", + "moon", "orbit", - "toolkit", "space", - "satellite" + "toolkit" ], "author": "Theodore Kruczek (https://github.com/thkruz/ootk-core/)", "license": "MIT", @@ -50,11 +53,11 @@ "jest": "^28.1.3", "prettier": "^2.8.8", "prettier-plugin-organize-imports": "^3.2.3", - "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", + "tsx": "^4.7.0", "ttypescript": "^1.5.15", "typescript": "^4.9.5", "typescript-transform-paths": "^3.4.6" }, "homepage": "https://github.com/thkruz/ootk" -} \ No newline at end of file +} diff --git a/scripts/cleanup.mjs b/scripts/cleanup.mjs index fd22fee..9270aac 100644 --- a/scripts/cleanup.mjs +++ b/scripts/cleanup.mjs @@ -14,3 +14,10 @@ try { } catch (error) { // Intentionally left blank } + +console.log('Removing ./mjs...'); +try { + rimraf.sync('./mjs'); +} catch (error) { + // Intentionally left blank +} diff --git a/scripts/makeMjs.mjs b/scripts/makeMjs.mjs index 74b8d0f..e6db7e7 100644 --- a/scripts/makeMjs.mjs +++ b/scripts/makeMjs.mjs @@ -3,3 +3,5 @@ import { cpSync } from 'fs'; cpSync('./lib/index.js', './lib/index.mjs'); cpSync('./lib/index.js.map', './lib/index.mjs.map'); cpSync('./lib/index.d.ts', './lib/index.d.mts'); + +cpSync('./scripts/package.commonjs.json', './commonjs/package.json'); diff --git a/scripts/package.commonjs.json b/scripts/package.commonjs.json new file mode 100644 index 0000000..c9a4422 --- /dev/null +++ b/scripts/package.commonjs.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} \ No newline at end of file