@mark1russell7/guidebook-preparedness 0.7.23 → 0.7.24

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 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/data/sources.ts","../src/data/steps.ts","../src/data/gaps.ts","../src/data/coverage.ts","../src/data/rules.ts","../src/data/chart.ts","../src/data/topics.ts","../src/data/units.ts","../src/data/tab-units.ts","../src/data/bundles.ts","../src/data/media.ts","../src/index.ts"],"mappings":";;;;;qBAOa;;qBAKA,kBAAkB;;qBC6DlB,qBAAqB;;;;;qBA6hBrB,oBAAoB;;qBAgSpB,gBAAgB;;qBC13BhB,eAAe;;;;;qBCLf;;qBCEA,gBAAgB;;qBCwBhB;;qBAGA;;;;;qBAQA,iBAAiB;;qBCrCjB;;qBAyDA,iBAAiB;;qBCg2EjB,sBAAsB;;qBCp/BtB,oBAAoB;;qBCn6CpB;;;;;;qBAOA;;qBAKA,kBAAkB;;;;;;qBAwBlB,gBAAgB;;qBCtChB,sBAAsB;;qBA8CtB,eAAe,SAAS,QAAQ,OAAO;WAAuB;WAA6B;;;;;;;;;qBAY3F,cAAc,SAAS;WAA0B,MAAM;WAAqB,MAAM;WAAqB;;;;;;qBAYvG,sBAAsB;;;;;qBCrDtB;;;;;qBAmBA;;qBAGA;;qBAGA;;;qBAIA;qBAEA,eAAe;;qBAGf,kBAAkB;;qBAGlB,OAAO"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/data/sources.ts","../src/data/steps.ts","../src/data/gaps.ts","../src/data/coverage.ts","../src/data/rules.ts","../src/data/chart.ts","../src/data/topics.ts","../src/data/units.ts","../src/data/tab-units.ts","../src/data/bundles.ts","../src/data/media.ts","../src/index.ts"],"mappings":";;;;;qBAOa;;qBAKA,kBAAkB;;qBCgFlB,qBAAqB;;;;;qBA6hBrB,oBAAoB;;qBAgSpB,gBAAgB;;qBC74BhB,eAAe;;;;;qBCLf;;qBCEA,gBAAgB;;qBCwBhB;;qBAGA;;;;;qBAQA,iBAAiB;;qBCrCjB;;qBAyDA,iBAAiB;;qBCg2EjB,sBAAsB;;qBCp/BtB,oBAAoB;;qBCn6CpB;;;;;;qBAOA;;qBAKA,kBAAkB;;;;;;qBAwBlB,gBAAgB;;qBCtChB,sBAAsB;;qBA8CtB,eAAe,SAAS,QAAQ,OAAO;WAAuB;WAA6B;;;;;;;;;qBAY3F,cAAc,SAAS;WAA0B,MAAM;WAAqB,MAAM;WAAqB;;;;;;qBAYvG,sBAAsB;;;;;qBCrDtB;;;;;qBAmBA;;qBAGA;;qBAGA;;;qBAIA;qBAEA,eAAe;;qBAGf,kBAAkB;;qBAGlB,OAAO"}
package/build/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { GRAPH_SCHEMA, SOCIETY_STATES } from "@mark1russell7/guidebook-plans";
2
+ import { app, key, lit, ref, serialize } from "@mark1russell7/vex";
2
3
  // src/data/chart.ts
3
4
  const ALL = [
4
5
  "ready",
@@ -538,7 +539,7 @@ function hazardsOf(steps) {
538
539
  function stepsOf(on, rows) {
539
540
  const count = /* @__PURE__ */ new Map();
540
541
  return rows.map(([phase, name, action, sources, more = []]) => {
541
- const { needs = [], reasoning, society } = Array.isArray(more) ? { needs: more } : more;
542
+ const { needs = [], reasoning, society, when } = Array.isArray(more) ? { needs: more } : more;
542
543
  const order = (count.get(phase) ?? 0) + 1;
543
544
  count.set(phase, order);
544
545
  return {
@@ -550,10 +551,25 @@ function stepsOf(on, rows) {
550
551
  order,
551
552
  sources,
552
553
  ...reasoning === void 0 ? {} : { reasoning },
553
- ...society === void 0 ? {} : { society }
554
+ ...society === void 0 ? {} : { society },
555
+ ...when === void 0 ? {} : { when }
554
556
  };
555
557
  });
556
558
  }
559
+ /**
560
+ * This function gives the JSON form of a condition `when`: a Vex program over the live keys.
561
+ * Each live key has the field `stopped`, and a stopped key with a known start has the field `hours`.
562
+ * A step gets a `when` only if the live keys decide its condition. A condition that a person sees (a smell, the weather) gets no `when`.
563
+ */
564
+ function condition(expr) {
565
+ const text = serialize(expr);
566
+ if (!text.ok) throw new Error("the condition does not serialize");
567
+ return text.value;
568
+ }
569
+ /** The expression that is true when the live key `part` is stopped. */
570
+ const stopped = (part) => ref(["stopped"], [key(part)]);
571
+ /** The expression that is true when the live key `part` is stopped for more than `hours` hours. */
572
+ const stoppedOver = (part, hours) => app("and", stopped(part), app("gt", ref(["hours"], [key(part)]), lit(hours)));
557
573
  const DRINK = "hydration.drink";
558
574
  const FOOD$2 = "food.energy";
559
575
  const MEDICINE$1 = "health.medicine";
@@ -2075,7 +2091,8 @@ const CASE_STEPS = [
2075
2091
  "P1",
2076
2092
  "radio-info",
2077
2093
  "If the phone and data networks stop, get the news from the public radio on batteries.",
2078
- ["fi-72h-info"]
2094
+ ["fi-72h-info"],
2095
+ { when: condition(app("and", stopped("phone.network"), stopped("network.access"))) }
2079
2096
  ],
2080
2097
  [
2081
2098
  "P1",
@@ -3876,7 +3893,10 @@ const CUT_STEPS = [
3876
3893
  "medicine",
3877
3894
  "After more than one day with no power, discard refrigerated medicine, unless its label tells otherwise.",
3878
3895
  ["ready-power"],
3879
- [MEDICINE$1]
3896
+ {
3897
+ needs: [MEDICINE$1],
3898
+ when: condition(stoppedOver("power.grid", 24))
3899
+ }
3880
3900
  ],
3881
3901
  [
3882
3902
  "P3",