react-hook-visible-satellites
Advanced tools
Comparing version 1.1.1 to 2.0.0
@@ -9,4 +9,4 @@ 'use strict'; | ||
var React__default = _interopDefault(React); | ||
var tle_js = require('tle.js'); | ||
var ramda = require('ramda'); | ||
var TLEJS = require('tle.js'); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
@@ -76,3 +76,2 @@ | ||
const tlejs = new TLEJS(); | ||
/** | ||
@@ -97,3 +96,4 @@ * | ||
} = satellites; | ||
let tles; | ||
let tles; // TODO: move to useEffect scope. | ||
let isPaused = false; | ||
@@ -106,3 +106,4 @@ let visible; | ||
React.useEffect(() => { | ||
tles = splitRawTLEs(rawTLEs); | ||
const tleArr = splitRawTLEs(rawTLEs); | ||
tles = ramda.uniqBy(arr => arr[1], tleArr); | ||
recalculateAllPositions(); | ||
@@ -124,3 +125,8 @@ setSatellites({ | ||
setSatellites({ ...satellites, | ||
visibleSatellites: [...slowMoving, ...tlejs.getVisibleSatellites(lat, lng, 0, fastMovingTLEs)] | ||
visibleSatellites: [...slowMoving, ...tle_js.getVisibleSatellites({ | ||
observerLat: lat, | ||
observerLng: lng, | ||
observerHeight: 0, | ||
tles: fastMovingTLEs | ||
})] | ||
}); | ||
@@ -142,3 +148,8 @@ }, refreshMS); | ||
function recalculateAllPositions() { | ||
visible = tlejs.getVisibleSatellites(lat, lng, 0, tles); | ||
visible = tle_js.getVisibleSatellites({ | ||
observerLat: lat, | ||
observerLng: lng, | ||
observerHeight: 0, | ||
tles | ||
}); | ||
slowMoving = visible.filter(satellite => satellite.info.velocity / satellite.info.range <= 0.001); | ||
@@ -215,3 +226,2 @@ fastMoving = visible.filter(satellite => satellite.info.velocity / satellite.info.range > 0.001); | ||
} = props; | ||
console.log(44, tles); | ||
const [visibleSatellites, { | ||
@@ -448,3 +458,3 @@ pause, | ||
style: style | ||
}, React__default.createElement("button", { | ||
}, document.fullscreenEnabled && React__default.createElement("button", { | ||
onClick: handleToggleFullscreen | ||
@@ -451,0 +461,0 @@ }, "Toggle fullscreen"), React__default.createElement(Canvas, { |
import React, { useState, useEffect, useRef } from 'react'; | ||
import { getVisibleSatellites } from 'tle.js'; | ||
import { splitEvery, uniqBy, sort } from 'ramda'; | ||
import * as TLEJS from 'tle.js'; | ||
import PropTypes from 'prop-types'; | ||
@@ -68,3 +68,2 @@ | ||
const tlejs = new TLEJS(); | ||
/** | ||
@@ -89,3 +88,4 @@ * | ||
} = satellites; | ||
let tles; | ||
let tles; // TODO: move to useEffect scope. | ||
let isPaused = false; | ||
@@ -98,3 +98,4 @@ let visible; | ||
useEffect(() => { | ||
tles = splitRawTLEs(rawTLEs); | ||
const tleArr = splitRawTLEs(rawTLEs); | ||
tles = uniqBy(arr => arr[1], tleArr); | ||
recalculateAllPositions(); | ||
@@ -116,3 +117,8 @@ setSatellites({ | ||
setSatellites({ ...satellites, | ||
visibleSatellites: [...slowMoving, ...tlejs.getVisibleSatellites(lat, lng, 0, fastMovingTLEs)] | ||
visibleSatellites: [...slowMoving, ...getVisibleSatellites({ | ||
observerLat: lat, | ||
observerLng: lng, | ||
observerHeight: 0, | ||
tles: fastMovingTLEs | ||
})] | ||
}); | ||
@@ -134,3 +140,8 @@ }, refreshMS); | ||
function recalculateAllPositions() { | ||
visible = tlejs.getVisibleSatellites(lat, lng, 0, tles); | ||
visible = getVisibleSatellites({ | ||
observerLat: lat, | ||
observerLng: lng, | ||
observerHeight: 0, | ||
tles | ||
}); | ||
slowMoving = visible.filter(satellite => satellite.info.velocity / satellite.info.range <= 0.001); | ||
@@ -207,3 +218,2 @@ fastMoving = visible.filter(satellite => satellite.info.velocity / satellite.info.range > 0.001); | ||
} = props; | ||
console.log(44, tles); | ||
const [visibleSatellites, { | ||
@@ -440,3 +450,3 @@ pause, | ||
style: style | ||
}, React.createElement("button", { | ||
}, document.fullscreenEnabled && React.createElement("button", { | ||
onClick: handleToggleFullscreen | ||
@@ -443,0 +453,0 @@ }, "Toggle fullscreen"), React.createElement(Canvas, { |
{ | ||
"name": "react-hook-visible-satellites", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "Computes and displays satellites currently visible overhead.", | ||
@@ -10,2 +10,3 @@ "main": "dist/react-hook-visible-satellites.cjs.js", | ||
"start": "start-storybook", | ||
"dev": "npm start", | ||
"build-storybook": "build-storybook -c .storybook -o .storybook-out", | ||
@@ -38,36 +39,36 @@ "storybook-publish": "npm run build-storybook && cp -r .storybook-out/* ../davidcalhoun.github.io/react-hook-visible-satellites/ && cd ../davidcalhoun.github.io/react-hook-visible-satellites/", | ||
"devDependencies": { | ||
"@babel/core": "^7.6.4", | ||
"@babel/plugin-proposal-export-default-from": "^7.5.2", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/preset-react": "^7.6.3", | ||
"@storybook/addon-docs": "^5.2.6", | ||
"@storybook/react": "^5.2.6", | ||
"@testing-library/dom": "^6.10.0", | ||
"@testing-library/jest-dom": "^4.2.0", | ||
"@testing-library/react": "^9.3.0", | ||
"babel-eslint": "^10.0.3", | ||
"babel-jest": "^24.9.0", | ||
"@babel/core": "^7.8.6", | ||
"@babel/plugin-proposal-export-default-from": "^7.8.3", | ||
"@babel/preset-env": "^7.8.6", | ||
"@babel/preset-react": "^7.8.3", | ||
"@storybook/addon-docs": "^5.3.14", | ||
"@storybook/react": "^5.3.14", | ||
"@testing-library/dom": "^6.12.2", | ||
"@testing-library/jest-dom": "^5.1.1", | ||
"@testing-library/react": "^9.4.1", | ||
"babel-eslint": "^10.1.0", | ||
"babel-jest": "^25.1.0", | ||
"babel-loader": "^8.0.6", | ||
"eslint": "^6.6.0", | ||
"eslint-plugin-react": "^7.16.0", | ||
"eslint-plugin-react-hooks": "^2.2.0", | ||
"file-loader": "^4.3.0", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-react": "^7.18.3", | ||
"eslint-plugin-react-hooks": "^2.5.0", | ||
"file-loader": "^5.1.0", | ||
"identity-obj-proxy": "^3.0.0", | ||
"jest": "^24.9.0", | ||
"jest": "^25.1.0", | ||
"postcss-loader": "^3.0.0", | ||
"prettier": "^1.18.2", | ||
"prop-types": "^15.7.2", | ||
"raw-loader": "^3.1.0", | ||
"react": "^16.11.0", | ||
"react-dom": "^16.11.0", | ||
"raw-loader": "^4.0.0", | ||
"react": "^16.13.0", | ||
"react-dom": "^16.13.0", | ||
"react-transition-group": "^4.3.0", | ||
"rollup": "^1.25.2", | ||
"rollup": "^1.31.1", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-postcss": "^2.0.3", | ||
"style-loader": "^1.0.0" | ||
"rollup-plugin-postcss": "^2.1.1", | ||
"style-loader": "^1.1.3" | ||
}, | ||
"dependencies": { | ||
"ramda": "^0.26.1", | ||
"tle.js": "^2.1.3" | ||
"ramda": "^0.27.0", | ||
"tle.js": "^4.0.0" | ||
}, | ||
@@ -74,0 +75,0 @@ "peerDependencies": { |
import { useState, useEffect } from "react"; | ||
import { getVisibleSatellites } from "tle.js"; | ||
import { uniqBy } from "ramda"; | ||
import { splitRawTLEs, useVisibilityChange } from "./utils"; | ||
import * as TLEJS from "tle.js"; | ||
const tlejs = new TLEJS(); | ||
@@ -20,3 +21,6 @@ /** | ||
}); | ||
let [documentIsVisible, { setVisibilityListener, unsetVisibilityListener }] = useVisibilityChange(); | ||
let [ | ||
documentIsVisible, | ||
{ setVisibilityListener, unsetVisibilityListener } | ||
] = useVisibilityChange(); | ||
@@ -29,3 +33,3 @@ let { | ||
let tles; | ||
let tles; // TODO: move to useEffect scope. | ||
let isPaused = false; | ||
@@ -39,3 +43,4 @@ let visible; | ||
useEffect(() => { | ||
tles = splitRawTLEs(rawTLEs); | ||
const tleArr = splitRawTLEs(rawTLEs); | ||
tles = uniqBy(arr => arr[1], tleArr); | ||
@@ -65,3 +70,8 @@ recalculateAllPositions(); | ||
...slowMoving, | ||
...tlejs.getVisibleSatellites(lat, lng, 0, fastMovingTLEs) | ||
...getVisibleSatellites({ | ||
observerLat: lat, | ||
observerLng: lng, | ||
observerHeight: 0, | ||
tles: fastMovingTLEs | ||
}) | ||
] | ||
@@ -85,3 +95,9 @@ }); | ||
function recalculateAllPositions() { | ||
visible = tlejs.getVisibleSatellites(lat, lng, 0, tles); | ||
visible = getVisibleSatellites({ | ||
observerLat: lat, | ||
observerLng: lng, | ||
observerHeight: 0, | ||
tles | ||
}); | ||
slowMoving = visible.filter( | ||
@@ -88,0 +104,0 @@ satellite => satellite.info.velocity / satellite.info.range <= 0.001 |
@@ -203,3 +203,7 @@ import React, { useEffect, useRef } from "react"; | ||
<div className={styles.container} ref={container} style={style}> | ||
<button onClick={handleToggleFullscreen}>Toggle fullscreen</button> | ||
{ | ||
document.fullscreenEnabled && ( | ||
<button onClick={handleToggleFullscreen}>Toggle fullscreen</button> | ||
) | ||
} | ||
<Canvas satellites={forDisplay} className={styles.canvas} /> | ||
@@ -206,0 +210,0 @@ </div> |
@@ -11,4 +11,2 @@ import React, { useEffect } from "react"; | ||
console.log(44, tles) | ||
const [ | ||
@@ -15,0 +13,0 @@ visibleSatellites, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1415577
1538
+ Addedramda@0.27.2(transitive)
+ Addedsatellite.js@4.1.4(transitive)
+ Addedtle.js@4.9.0(transitive)
- Removedramda@0.26.1(transitive)
- Removedsatellite.js@3.0.1(transitive)
- Removedtle.js@2.1.3(transitive)
Updatedramda@^0.27.0
Updatedtle.js@^4.0.0