@sjvair/monitor-map 3.2.1 → 3.2.2

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.
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { MonitorsMeta, SJVAirMonitorDeviceMeta } from "@sjvair/sdk";
2
+ import type { MonitorsMeta } from "@sjvair/sdk";
3
3
  import DisplayOption from "../../components/DisplayOption.svelte";
4
4
  import SegmentedControl from "../../components/SegmentedControl.svelte";
5
5
  import ToggleSwitch from "../../components/ToggleSwitch.svelte";
@@ -22,17 +22,28 @@
22
22
  }
23
23
  ];
24
24
 
25
- const monitorDisplayOptions = $derived.by(() => {
26
- return Object.entries(monitorsMapIntegration.displayOptions).filter(
27
- ([key, opt]) =>
28
- key === "inactive" ||
29
- monitorsManager.meta?.asIter.monitors.some(
30
- (m: SJVAirMonitorDeviceMeta) =>
31
- m.label === opt.label &&
32
- monitorsManager.pollutant &&
33
- monitorsManager.pollutant in m.entries
34
- )
25
+ // "inside" is a location filter (indoor vs outdoor), not tied to a monitor type or
26
+ // pollutant, so it's always shown, like "inactive".
27
+ const uiOnlyDisplayOptions = new Set(["inactive", "inside"]);
28
+
29
+ // "sjvair" (SJVAir non-FEM) isn't its own backend monitor type — it groups is_sjvair-flagged
30
+ // purpleair devices with airgradient devices (see monitorsMapIntegration.filters/featuresByType),
31
+ // so its visibility follows whichever of those two types supports the current pollutant.
32
+ const sjvairUnderlyingTypes = ["purpleair", "airgradient"];
33
+
34
+ function pollutantSupportedByType(type: string): boolean {
35
+ const deviceMeta = monitorsManager.meta?.monitors[type];
36
+ return (
37
+ !!deviceMeta && !!monitorsManager.pollutant && monitorsManager.pollutant in deviceMeta.entries
35
38
  );
39
+ }
40
+
41
+ const monitorDisplayOptions = $derived.by(() => {
42
+ return Object.entries(monitorsMapIntegration.displayOptions).filter(([key]) => {
43
+ if (uiOnlyDisplayOptions.has(key)) return true;
44
+ if (key === "sjvair") return sjvairUnderlyingTypes.some(pollutantSupportedByType);
45
+ return pollutantSupportedByType(key);
46
+ });
36
47
  });
37
48
 
38
49
  $effect(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sjvair/monitor-map",
3
3
  "description": "SJVAir's interactive monitor map",
4
- "version": "3.2.1",
4
+ "version": "3.2.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SJVAir/monitor-map"
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { MonitorsMeta, SJVAirMonitorDeviceMeta } from "@sjvair/sdk";
2
+ import type { MonitorsMeta } from "@sjvair/sdk";
3
3
  import DisplayOption from "$lib/components/DisplayOption.svelte";
4
4
  import SegmentedControl from "$lib/components/SegmentedControl.svelte";
5
5
  import ToggleSwitch from "$lib/components/ToggleSwitch.svelte";
@@ -22,17 +22,28 @@
22
22
  }
23
23
  ];
24
24
 
25
- const monitorDisplayOptions = $derived.by(() => {
26
- return Object.entries(monitorsMapIntegration.displayOptions).filter(
27
- ([key, opt]) =>
28
- key === "inactive" ||
29
- monitorsManager.meta?.asIter.monitors.some(
30
- (m: SJVAirMonitorDeviceMeta) =>
31
- m.label === opt.label &&
32
- monitorsManager.pollutant &&
33
- monitorsManager.pollutant in m.entries
34
- )
25
+ // "inside" is a location filter (indoor vs outdoor), not tied to a monitor type or
26
+ // pollutant, so it's always shown, like "inactive".
27
+ const uiOnlyDisplayOptions = new Set(["inactive", "inside"]);
28
+
29
+ // "sjvair" (SJVAir non-FEM) isn't its own backend monitor type — it groups is_sjvair-flagged
30
+ // purpleair devices with airgradient devices (see monitorsMapIntegration.filters/featuresByType),
31
+ // so its visibility follows whichever of those two types supports the current pollutant.
32
+ const sjvairUnderlyingTypes = ["purpleair", "airgradient"];
33
+
34
+ function pollutantSupportedByType(type: string): boolean {
35
+ const deviceMeta = monitorsManager.meta?.monitors[type];
36
+ return (
37
+ !!deviceMeta && !!monitorsManager.pollutant && monitorsManager.pollutant in deviceMeta.entries
35
38
  );
39
+ }
40
+
41
+ const monitorDisplayOptions = $derived.by(() => {
42
+ return Object.entries(monitorsMapIntegration.displayOptions).filter(([key]) => {
43
+ if (uiOnlyDisplayOptions.has(key)) return true;
44
+ if (key === "sjvair") return sjvairUnderlyingTypes.some(pollutantSupportedByType);
45
+ return pollutantSupportedByType(key);
46
+ });
36
47
  });
37
48
 
38
49
  $effect(() => {