@zac-apps/helium 1.0.0 → 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 +61 -12
  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,10 +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) {
1571
+ var basePath = props.basePath || "";
1572
+
1544
1573
  // State
1545
1574
 
1546
- var _useImmer = useImmer(null),
1575
+ var _useImmer = useImmer({}),
1547
1576
  _useImmer2 = _slicedToArray(_useImmer, 2),
1548
1577
  heliumData = _useImmer2[0],
1549
1578
  SetHeliumData = _useImmer2[1];
@@ -1555,6 +1584,10 @@ function Helium(props) {
1555
1584
  _useState4 = _slicedToArray(_useState3, 2),
1556
1585
  preprocessed = _useState4[0],
1557
1586
  SetPreprocessed = _useState4[1];
1587
+ var _useState5 = useState({}),
1588
+ _useState6 = _slicedToArray(_useState5, 2);
1589
+ _useState6[0];
1590
+ var SetHeliumError = _useState6[1];
1558
1591
 
1559
1592
  // Query Media size for responsive column wrapping
1560
1593
 
@@ -1565,18 +1598,16 @@ function Helium(props) {
1565
1598
 
1566
1599
  // fetch data
1567
1600
 
1568
- var heliumLookupData = PublicFetch({
1569
- url: "/heliumLookup.json"
1570
- });
1571
1601
  var fetchGraph = PublicFetch({
1572
- url: "/graphdata.json"
1602
+ url: basePath + "/graphdata.json"
1573
1603
  });
1574
1604
  PublicFetch({
1575
- url: "/helium.json",
1576
- SetState: SetHeliumData
1605
+ url: basePath + "/helium.json",
1606
+ SetState: SetHeliumData,
1607
+ SetError: SetHeliumError
1577
1608
  });
1578
1609
  useEffect(function () {
1579
- if (heliumData) {
1610
+ if (heliumData && heliumData.helium) {
1580
1611
  Object.keys(heliumData.helium).map(function (spec) {
1581
1612
  SetHeliumData(function (heliumData) {
1582
1613
  heliumData.helium[spec] = Number(heliumData.helium[spec]);
@@ -1588,14 +1619,32 @@ function Helium(props) {
1588
1619
 
1589
1620
  // Catch empty data
1590
1621
 
1591
- 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) {
1592
1641
  return /*#__PURE__*/jsx(Progress, {});
1593
1642
  }
1594
1643
  var graphDataMeta = fetchGraph.meta;
1595
1644
  var graphData = _objectSpread({}, fetchGraph);
1596
1645
  delete graphData.meta;
1597
1646
  if (!graphDataMeta) {
1598
- return /*#__PURE__*/jsx(Progress, {});
1647
+ graphDataMeta = {};
1599
1648
  }
1600
1649
  return /*#__PURE__*/jsx(AppGrid, {
1601
1650
  children: /*#__PURE__*/jsxs(LookupContext.Provider, {
@@ -1624,9 +1673,9 @@ function Helium(props) {
1624
1673
  children: [/*#__PURE__*/jsx("strong", {
1625
1674
  children: "Current levels"
1626
1675
  }), " ", /*#__PURE__*/jsxs("em", {
1627
- 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, {
1628
1677
  levelsEdited: levelsEdited
1629
- }), ")"]
1678
+ })]
1630
1679
  })]
1631
1680
  })
1632
1681
  }), /*#__PURE__*/jsx(Grid, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zac-apps/helium",
3
- "version": "1.0.0",
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",