@mark1russell7/guidebook-preparedness 0.7.46 → 0.7.48
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.
- package/build/index.d.ts.map +1 -1
- package/build/index.js +46 -2
- package/build/index.js.map +1 -1
- package/package.json +5 -5
- package/src/data/steps.ts +8 -2
- package/src/data/uses.ts +41 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/guidebook-preparedness",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.48",
|
|
5
5
|
"description": "The preparedness content of the guidebook: cited sources, the steps and marked gaps of 12 cases and 6 cuts, 40 topics in 12 areas, and the catalog of offline bundles.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"guidebook",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"vitest": "^5.0.3"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@mark1russell7/guidebook": "0.
|
|
60
|
-
"@mark1russell7/guidebook-library": "0.
|
|
61
|
-
"@mark1russell7/guidebook-plans": "0.3.
|
|
62
|
-
"@mark1russell7/guidebook-topics": "0.1.
|
|
59
|
+
"@mark1russell7/guidebook": "0.7.0",
|
|
60
|
+
"@mark1russell7/guidebook-library": "0.5.0",
|
|
61
|
+
"@mark1russell7/guidebook-plans": "0.3.9",
|
|
62
|
+
"@mark1russell7/guidebook-topics": "0.1.9",
|
|
63
63
|
"@mark1russell7/vex": "^0.20.2"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
package/src/data/steps.ts
CHANGED
|
@@ -4,20 +4,26 @@
|
|
|
4
4
|
import type { Phase, Society, Step } from "@mark1russell7/guidebook-plans";
|
|
5
5
|
import { app, key, lit, ref, serialize } from "@mark1russell7/vex";
|
|
6
6
|
import type { Expr } from "@mark1russell7/vex";
|
|
7
|
+
import { STEP_USES } from "./uses.ts";
|
|
7
8
|
|
|
8
9
|
/** One row of a key: the phase, a short name, the action, the sources and the needs that the step protects. */
|
|
9
10
|
/** The more fields of a row: the needs that the step protects, its reasoning, the states of society that it is for, and its condition. */
|
|
10
11
|
type More = { readonly needs?: readonly string[]; readonly reasoning?: string; readonly society?: readonly Society[]; readonly when?: string };
|
|
11
12
|
type Row = readonly [phase: Phase, name: string, action: string, sources: readonly string[], more?: readonly string[] | More];
|
|
12
13
|
|
|
13
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* This function makes the steps of a key from its rows. The order of a step is its position among the rows of its phase.
|
|
16
|
+
* The items that a step uses come from `STEP_USES`, by the id of the step.
|
|
17
|
+
*/
|
|
14
18
|
function stepsOf(on: string, rows: readonly Row[]): Step[] {
|
|
15
19
|
const count = new Map<Phase, number>();
|
|
16
20
|
return rows.map(([phase, name, action, sources, more = []]) => {
|
|
17
21
|
const { needs = [], reasoning, society, when } = Array.isArray(more) ? { needs: more as readonly string[] } : (more as More);
|
|
18
22
|
const order = (count.get(phase) ?? 0) + 1;
|
|
19
23
|
count.set(phase, order);
|
|
20
|
-
|
|
24
|
+
const id = `${on}.${phase}.${name}`;
|
|
25
|
+
const uses = STEP_USES[id];
|
|
26
|
+
return { id, on, phase, needs, do: action, ...(uses === undefined ? {} : { uses }), order, sources, ...(reasoning === undefined ? {} : { reasoning }), ...(society === undefined ? {} : { society }), ...(when === undefined ? {} : { when }) };
|
|
21
27
|
});
|
|
22
28
|
}
|
|
23
29
|
|
package/src/data/uses.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// The items that each step uses, by the id of the step. Each item is the id of a product of the supply catalog of
|
|
2
|
+
// `@mark1russell7/market/supplies`. A planner joins a step to the stock and the buy list with these ids.
|
|
3
|
+
//
|
|
4
|
+
// A step gets an item only when its action needs that item. A step that names an FM or AM radio, a local or a public
|
|
5
|
+
// station, or shortwave gets no radio: the catalog has no product for these radios. The weather radio receives only the
|
|
6
|
+
// stations of the weather service.
|
|
7
|
+
|
|
8
|
+
const WEATHER_RADIO = "communication.noaa-radio";
|
|
9
|
+
const TWO_WAY_RADIOS = "communication.frs-radio-pair";
|
|
10
|
+
const FLASHLIGHT = "light.flashlight";
|
|
11
|
+
const CELLS = "power.aa-alkaline";
|
|
12
|
+
const FIRST_AID_KIT = "first-aid.kit";
|
|
13
|
+
const SLEEPING_BAG = "heat.sleeping-bag";
|
|
14
|
+
|
|
15
|
+
/** The items that each step uses, by the `id` of the step. A test holds that each key is the id of a step. */
|
|
16
|
+
export const STEP_USES: Readonly<Record<string, readonly string[]>> = {
|
|
17
|
+
"met.winter.storm.ready.supplies": [WEATHER_RADIO, FLASHLIGHT, CELLS],
|
|
18
|
+
"met.winter.storm.ready.car-kit": [FLASHLIGHT],
|
|
19
|
+
"met.tornado.P1.listen": [WEATHER_RADIO],
|
|
20
|
+
"cbrne.hazardous-materials.warned.listen": [WEATHER_RADIO],
|
|
21
|
+
"cbrne.radiological.ready.radio": [WEATHER_RADIO, CELLS],
|
|
22
|
+
"cbrne.radiological.warned.inside": [WEATHER_RADIO],
|
|
23
|
+
"health.medical-emergency.ready.first-aid-kit": [FIRST_AID_KIT],
|
|
24
|
+
"civic.ai-collapse.ready.radio": [WEATHER_RADIO, CELLS],
|
|
25
|
+
"civic.ai-collapse.P0.shelter": [WEATHER_RADIO],
|
|
26
|
+
"infra.power.grid-collapse.ready.warm": [SLEEPING_BAG],
|
|
27
|
+
"cbrne.nuclear-detonation.ready.alerts-and-radio": [WEATHER_RADIO, CELLS],
|
|
28
|
+
"security.nuclear-war.ready.radio": [WEATHER_RADIO, CELLS],
|
|
29
|
+
"security.nuclear-war.warned.public-warning": [WEATHER_RADIO],
|
|
30
|
+
"cbrne.emp.ready.spare-batteries": [CELLS],
|
|
31
|
+
"cbrne.emp.P1.listen-radio": [WEATHER_RADIO],
|
|
32
|
+
"security.armed-conflict.ready.radio": [WEATHER_RADIO, CELLS],
|
|
33
|
+
"power.grid.ready.flashlights": [FLASHLIGHT],
|
|
34
|
+
"phone.network.ready.radio": [WEATHER_RADIO, CELLS],
|
|
35
|
+
"phone.network.ready.radios": [TWO_WAY_RADIOS],
|
|
36
|
+
"phone.network.P4.two-way-radio": [TWO_WAY_RADIOS],
|
|
37
|
+
"network.access.ready.radio": [WEATHER_RADIO, CELLS],
|
|
38
|
+
"care.local.P3.medic": [FIRST_AID_KIT],
|
|
39
|
+
"fuel.retail.ready.warm-layers": [SLEEPING_BAG],
|
|
40
|
+
"home.dwelling.P1.radio": [WEATHER_RADIO, CELLS],
|
|
41
|
+
};
|