@zac-apps/helium 1.0.1 → 1.0.2-beta.1

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.
Files changed (2) hide show
  1. package/dist/index.js +57 -10
  2. package/package.json +17 -17
package/dist/index.js CHANGED
@@ -1500,6 +1500,29 @@ function HeliumGraph(_ref4) {
1500
1500
  matches = _ref4.matches;
1501
1501
  var height = matches ? 250 : 200;
1502
1502
  var width = matches ? 300 : 280;
1503
+
1504
+ // Catch missing data
1505
+
1506
+ if (graphData.error) {
1507
+ return /*#__PURE__*/jsxs(React.Fragment, {
1508
+ children: [/*#__PURE__*/jsx(DivTitle, {
1509
+ children: /*#__PURE__*/jsx("strong", {
1510
+ children: "Helium level monitoring"
1511
+ })
1512
+ }), /*#__PURE__*/jsx(Grid, {
1513
+ sx: {
1514
+ display: "flex",
1515
+ justifyContent: "center"
1516
+ },
1517
+ children: /*#__PURE__*/jsx("em", {
1518
+ children: "No graph data available"
1519
+ })
1520
+ })]
1521
+ });
1522
+ }
1523
+
1524
+ // Render component
1525
+
1503
1526
  return /*#__PURE__*/jsxs(React.Fragment, {
1504
1527
  children: [/*#__PURE__*/jsxs(DivTitle, {
1505
1528
  children: [/*#__PURE__*/jsx("strong", {
@@ -1540,12 +1563,16 @@ function HeliumGraph(_ref4) {
1540
1563
 
1541
1564
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1542
1565
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1566
+ var heliumLookupData = require("/conf/heliumLookup.json");
1567
+
1568
+ // Principal function
1569
+
1543
1570
  function Helium(props) {
1544
1571
  var basePath = props.basePath || "";
1545
1572
 
1546
1573
  // State
1547
1574
 
1548
- var _useImmer = useImmer(null),
1575
+ var _useImmer = useImmer({}),
1549
1576
  _useImmer2 = _slicedToArray(_useImmer, 2),
1550
1577
  heliumData = _useImmer2[0],
1551
1578
  SetHeliumData = _useImmer2[1];
@@ -1557,6 +1584,10 @@ function Helium(props) {
1557
1584
  _useState4 = _slicedToArray(_useState3, 2),
1558
1585
  preprocessed = _useState4[0],
1559
1586
  SetPreprocessed = _useState4[1];
1587
+ var _useState5 = useState({}),
1588
+ _useState6 = _slicedToArray(_useState5, 2);
1589
+ _useState6[0];
1590
+ var SetHeliumError = _useState6[1];
1560
1591
 
1561
1592
  // Query Media size for responsive column wrapping
1562
1593
 
@@ -1567,18 +1598,16 @@ function Helium(props) {
1567
1598
 
1568
1599
  // fetch data
1569
1600
 
1570
- var heliumLookupData = PublicFetch({
1571
- url: basePath + "/heliumLookup.json"
1572
- });
1573
1601
  var fetchGraph = PublicFetch({
1574
1602
  url: basePath + "/graphdata.json"
1575
1603
  });
1576
1604
  PublicFetch({
1577
1605
  url: basePath + "/helium.json",
1578
- SetState: SetHeliumData
1606
+ SetState: SetHeliumData,
1607
+ SetError: SetHeliumError
1579
1608
  });
1580
1609
  useEffect(function () {
1581
- if (heliumData) {
1610
+ if (heliumData && heliumData.helium) {
1582
1611
  Object.keys(heliumData.helium).map(function (spec) {
1583
1612
  SetHeliumData(function (heliumData) {
1584
1613
  heliumData.helium[spec] = Number(heliumData.helium[spec]);
@@ -1590,14 +1619,32 @@ function Helium(props) {
1590
1619
 
1591
1620
  // Catch empty data
1592
1621
 
1593
- if (!heliumData || !heliumLookupData || !fetchGraph || preprocessed === false) {
1622
+ // useEffect(() => {
1623
+ // if (heliumData) {
1624
+ // SetHeliumData((heliumData) => {
1625
+ // heliumData.helium = {};
1626
+ // });
1627
+ // Object.keys(heliumLookupData.lookup).map((spec) => {
1628
+ // SetHeliumData((heliumData) => {
1629
+ // heliumData.helium[spec] = 0;
1630
+ // });
1631
+ // });
1632
+ // SetHeliumData((heliumData) => {
1633
+ // heliumData.meta = {};
1634
+ // heliumData.meta.date = 0;
1635
+ // });
1636
+ // SetPreprocessed(true);
1637
+ // }
1638
+ // }, [heliumError]);
1639
+
1640
+ if (!heliumData || !fetchGraph || !preprocessed) {
1594
1641
  return /*#__PURE__*/jsx(Progress, {});
1595
1642
  }
1596
1643
  var graphDataMeta = fetchGraph.meta;
1597
1644
  var graphData = _objectSpread({}, fetchGraph);
1598
1645
  delete graphData.meta;
1599
1646
  if (!graphDataMeta) {
1600
- return /*#__PURE__*/jsx(Progress, {});
1647
+ graphDataMeta = {};
1601
1648
  }
1602
1649
  return /*#__PURE__*/jsx(AppGrid, {
1603
1650
  children: /*#__PURE__*/jsxs(LookupContext.Provider, {
@@ -1626,9 +1673,9 @@ function Helium(props) {
1626
1673
  children: [/*#__PURE__*/jsx("strong", {
1627
1674
  children: "Current levels"
1628
1675
  }), " ", /*#__PURE__*/jsxs("em", {
1629
- children: ["(updated", " ", moment(heliumData.meta.date).fromNow(), /*#__PURE__*/jsx(EditAdmon, {
1676
+ children: [heliumData.meta.date || heliumData.meta.date !== 0 ? "(updated " + moment(heliumData.meta.date).fromNow() + ")" : "(manual)", /*#__PURE__*/jsx(EditAdmon, {
1630
1677
  levelsEdited: levelsEdited
1631
- }), ")"]
1678
+ })]
1632
1679
  })]
1633
1680
  })
1634
1681
  }), /*#__PURE__*/jsx(Grid, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zac-apps/helium",
3
- "version": "1.0.1",
3
+ "version": "1.0.2-beta.1",
4
4
  "scripts": {
5
5
  "rollup": "node_modules/rollup/dist/rollup.js",
6
6
  "dev": "next dev",
@@ -28,15 +28,15 @@
28
28
  "author": "ZAC",
29
29
  "license": "CC-BY-SA-4.0",
30
30
  "dependencies": {
31
- "@mui/icons-material": "^5.15.13",
32
- "@mui/material": "^5.15.13",
33
- "@zac-apps/commons": "^1.3.3",
31
+ "@mui/icons-material": "^5.15.14",
32
+ "@mui/material": "^5.15.14",
33
+ "@zac-apps/commons": "^1.3.5-beta.2",
34
34
  "moment": "^2.30.1",
35
35
  "recharts": "^2.12.3",
36
36
  "use-immer": "^0.9.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/plugin-transform-runtime": "^7.24.0",
39
+ "@babel/plugin-transform-runtime": "^7.24.3",
40
40
  "@emotion/react": "^11.11.4",
41
41
  "@emotion/styled": "^11.11.0",
42
42
  "@rollup/plugin-babel": "^6.0.4",
@@ -46,21 +46,21 @@
46
46
  "@semantic-release/git": "^10.0.1",
47
47
  "@semantic-release/gitlab": "^13.0.3",
48
48
  "@semantic-release/npm": "^12.0.0",
49
- "@storybook/addon-essentials": "^8.0.0",
50
- "@storybook/addon-interactions": "^8.0.0",
51
- "@storybook/addon-links": "^8.0.0",
52
- "@storybook/addon-onboarding": "^8.0.0",
53
- "@storybook/blocks": "^8.0.0",
54
- "@storybook/nextjs": "^8.0.0",
55
- "@storybook/react": "^8.0.0",
56
- "@storybook/test": "^8.0.0",
49
+ "@storybook/addon-essentials": "^8.0.5",
50
+ "@storybook/addon-interactions": "^8.0.5",
51
+ "@storybook/addon-links": "^8.0.5",
52
+ "@storybook/addon-onboarding": "^8.0.5",
53
+ "@storybook/blocks": "^8.0.5",
54
+ "@storybook/nextjs": "^8.0.5",
55
+ "@storybook/react": "^8.0.5",
56
+ "@storybook/test": "^8.0.5",
57
57
  "babel-loader": "^9.1.3",
58
58
  "eslint": "^8",
59
- "eslint-config-next": "14.1.3",
59
+ "eslint-config-next": "14.1.4",
60
60
  "eslint-plugin-storybook": "^0.8.0",
61
- "rollup": "^4.13.0",
62
- "semantic-release": "^23.0.5",
63
- "storybook": "^8.0.0"
61
+ "rollup": "^4.13.1",
62
+ "semantic-release": "^23.0.6",
63
+ "storybook": "^8.0.5"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "next": "^14.0.4",