@washy-washy/core 1.1.0 → 1.2.0
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/README.md +9 -2
- package/dist/browser.d.mts +2 -2
- package/dist/browser.mjs +2 -2
- package/dist/index.d.mts +10 -3
- package/dist/index.mjs +10 -3
- package/dist/index.mjs.map +1 -1
- package/dist/{mixing-DzbYAriI.mjs → mixing-DHXHkb3X.mjs} +135 -7
- package/dist/mixing-DHXHkb3X.mjs.map +1 -0
- package/dist/{rows-C-0YQE-w.d.mts → rows-BawMuBGc.d.mts} +134 -7
- package/package.json +8 -2
- package/schema/config.schema.json +200 -0
- package/dist/mixing-DzbYAriI.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@washy-washy/core)
|
|
5
5
|
[](https://codecov.io/gh/alrayyes/washy-washy-core)
|
|
6
6
|
[](LICENSE)
|
|
7
|
+
[](https://alrayyes.github.io/washy-washy-core/)
|
|
7
8
|
|
|
8
9
|
Chart parsing, machine validation, and mixing rules for
|
|
9
10
|
[washy-washy](https://github.com/alrayyes/washy-washy-cli), a laundry chart
|
|
@@ -70,14 +71,20 @@ const instructions = chartFromJson(jsonFromStorage, machine);
|
|
|
70
71
|
- **`parseConfig`**/**`configFromJson`**/**`configToJson`** do the same for a
|
|
71
72
|
machine and a chart together, as one `{ machine, chart }` object — the
|
|
72
73
|
chart is always validated against the machine it's embedded with.
|
|
74
|
+
`configToJson`'s output leads with a `$schema` key
|
|
75
|
+
([`schema/config.schema.json`](schema/config.schema.json), generated from
|
|
76
|
+
the `Config` type, so it can't drift) — an editor that reads it, VS Code
|
|
77
|
+
among them, validates and autocompletes the file with no setup.
|
|
73
78
|
- **`mixBlocker`**/**`canMix`**/**`resolve`** decide whether two piles of
|
|
74
79
|
laundry can share a drum, and why not when they can't.
|
|
75
80
|
- **`cardGroups`**/**`washGroups`**/**`ironGroups`** group instructions the
|
|
76
81
|
way a printed chart is laid out: one card per identical setup, a wash-only
|
|
77
82
|
cut, an iron-only cut ordered by thermostat position.
|
|
78
83
|
|
|
79
|
-
Every exported function and type carries a TSDoc comment
|
|
80
|
-
|
|
84
|
+
Every exported function and type carries a TSDoc comment with a runnable
|
|
85
|
+
example — that's your editor's hover, and it's also the generated
|
|
86
|
+
[API reference](https://alrayyes.github.io/washy-washy-core/).
|
|
87
|
+
[`@washy-washy/pdf`](https://alrayyes.github.io/washy-washy-pdf/) has the same.
|
|
81
88
|
|
|
82
89
|
## Development
|
|
83
90
|
|
package/dist/browser.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { Blocker, COLUMNS, ColourGroup, Config, Instruction, Iron, IronSetting, Machine, MixTag, ResolvedInstruction, Row, RowError, Variant, Washer, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
|
1
|
+
import { A as mixTags, C as ColourGroup, D as Variant, E as ResolvedInstruction, F as Washer, I as formatTemperature, L as ironSetting, M as Iron, N as IronSetting, O as colourGroups, P as Machine, R as ironSettingKeys, S as parseConfig, T as MixTag, _ as washGroups, a as chartToJson, b as configFromJson, c as Blocker, d as canMix, f as cardGroups, g as resolve, h as mixBlocker, i as chartFromJson, j as variants, k as durationsOf, l as blockerCode, m as loadGroups, n as Row, o as instructionsFromRows, p as ironGroups, r as RowError, s as rowsFromInstructions, t as COLUMNS, u as blockerLegend, v as CONFIG_SCHEMA_URL, w as Instruction, x as configToJson, y as Config, z as parseMachine } from "./rows-BawMuBGc.mjs";
|
|
2
|
+
export { Blocker, COLUMNS, CONFIG_SCHEMA_URL, ColourGroup, Config, Instruction, Iron, IronSetting, Machine, MixTag, ResolvedInstruction, Row, RowError, Variant, Washer, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
package/dist/browser.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { COLUMNS, RowError, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
|
1
|
+
import { C as variants, D as parseMachine, E as ironSettingKeys, S as mixTags, T as ironSetting, _ as chartToJson, a as ironGroups, b as colourGroups, c as resolve, d as configFromJson, f as configToJson, g as chartFromJson, h as RowError, i as cardGroups, l as washGroups, m as COLUMNS, n as blockerLegend, o as loadGroups, p as parseConfig, r as canMix, s as mixBlocker, t as blockerCode, u as CONFIG_SCHEMA_URL, v as instructionsFromRows, w as formatTemperature, x as durationsOf, y as rowsFromInstructions } from "./mixing-DHXHkb3X.mjs";
|
|
2
|
+
export { COLUMNS, CONFIG_SCHEMA_URL, RowError, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as mixTags, C as ColourGroup, D as Variant, E as ResolvedInstruction, F as Washer, I as formatTemperature, L as ironSetting, M as Iron, N as IronSetting, O as colourGroups, P as Machine, R as ironSettingKeys, S as parseConfig, T as MixTag, _ as washGroups, a as chartToJson, b as configFromJson, c as Blocker, d as canMix, f as cardGroups, g as resolve, h as mixBlocker, i as chartFromJson, j as variants, k as durationsOf, l as blockerCode, m as loadGroups, n as Row, o as instructionsFromRows, p as ironGroups, r as RowError, s as rowsFromInstructions, t as COLUMNS, u as blockerLegend, v as CONFIG_SCHEMA_URL, w as Instruction, x as configToJson, y as Config, z as parseMachine } from "./rows-BawMuBGc.mjs";
|
|
2
2
|
//#region src/csv.d.ts
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Parses the instruction CSV. See `instructionsFromRows` for the row rules.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const instructions = parseInstructions(csvFileContents, machine);
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
4
11
|
declare function parseInstructions(source: string, machine: Machine): Instruction[];
|
|
5
12
|
//#endregion
|
|
6
|
-
export { Blocker, COLUMNS, ColourGroup, Config, Instruction, Iron, IronSetting, Machine, MixTag, ResolvedInstruction, Row, RowError, Variant, Washer, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseInstructions, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
|
13
|
+
export { Blocker, COLUMNS, CONFIG_SCHEMA_URL, ColourGroup, Config, Instruction, Iron, IronSetting, Machine, MixTag, ResolvedInstruction, Row, RowError, Variant, Washer, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseInstructions, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
|
7
14
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as variants, D as parseMachine, E as ironSettingKeys, S as mixTags, T as ironSetting, _ as chartToJson, a as ironGroups, b as colourGroups, c as resolve, d as configFromJson, f as configToJson, g as chartFromJson, h as RowError, i as cardGroups, l as washGroups, m as COLUMNS, n as blockerLegend, o as loadGroups, p as parseConfig, r as canMix, s as mixBlocker, t as blockerCode, u as CONFIG_SCHEMA_URL, v as instructionsFromRows, w as formatTemperature, x as durationsOf, y as rowsFromInstructions } from "./mixing-DHXHkb3X.mjs";
|
|
2
2
|
import { parse } from "csv-parse/sync";
|
|
3
3
|
//#region src/csv.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Parses the instruction CSV. See `instructionsFromRows` for the row rules.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const instructions = parseInstructions(csvFileContents, machine);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
5
12
|
function parseInstructions(source, machine) {
|
|
6
13
|
const records = parse(source, {
|
|
7
14
|
columns: true,
|
|
@@ -13,6 +20,6 @@ function parseInstructions(source, machine) {
|
|
|
13
20
|
return instructionsFromRows(records, machine);
|
|
14
21
|
}
|
|
15
22
|
//#endregion
|
|
16
|
-
export { COLUMNS, RowError, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseInstructions, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
|
23
|
+
export { COLUMNS, CONFIG_SCHEMA_URL, RowError, blockerCode, blockerLegend, canMix, cardGroups, chartFromJson, chartToJson, colourGroups, configFromJson, configToJson, durationsOf, formatTemperature, instructionsFromRows, ironGroups, ironSetting, ironSettingKeys, loadGroups, mixBlocker, mixTags, parseConfig, parseInstructions, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
|
17
24
|
|
|
18
25
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/csv.ts"],"sourcesContent":["import { parse } from \"csv-parse/sync\";\nimport type { Machine } from \"./machine\";\nimport { instructionsFromRows } from \"./rows\";\nimport type { Instruction } from \"./types\";\n\n
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/csv.ts"],"sourcesContent":["import { parse } from \"csv-parse/sync\";\nimport type { Machine } from \"./machine\";\nimport { instructionsFromRows } from \"./rows\";\nimport type { Instruction } from \"./types\";\n\n/**\n * Parses the instruction CSV. See `instructionsFromRows` for the row rules.\n *\n * @example\n * ```ts\n * const instructions = parseInstructions(csvFileContents, machine);\n * ```\n */\nexport function parseInstructions(source: string, machine: Machine): Instruction[] {\n const records: Record<string, string>[] = parse(source, {\n columns: true,\n skip_empty_lines: true,\n trim: true,\n bom: true,\n });\n if (records.length === 0) throw new Error(\"the CSV has a header but no rows\");\n return instructionsFromRows(records, machine);\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,kBAAkB,QAAgB,SAAiC;CACjF,MAAM,UAAoC,MAAM,QAAQ;EACtD,SAAS;EACT,kBAAkB;EAClB,MAAM;EACN,KAAK;CACP,CAAC;CACD,IAAI,QAAQ,WAAW,GAAG,MAAM,IAAI,MAAM,kCAAkC;CAC5E,OAAO,qBAAqB,SAAS,OAAO;AAC9C"}
|
|
@@ -29,6 +29,12 @@ function parseIronSetting(value, index) {
|
|
|
29
29
|
* Checks a parsed machine file and hands back something the renderer can use.
|
|
30
30
|
* Every failure names the field, because the fix is always an edit to that
|
|
31
31
|
* line of JSON.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const machine = parseMachine(JSON.parse(machineFileContents));
|
|
36
|
+
* machine.washer.programs; // ["Off", "Cottons", "Wool", ...]
|
|
37
|
+
* ```
|
|
32
38
|
*/
|
|
33
39
|
function parseMachine(value) {
|
|
34
40
|
if (typeof value !== "object" || value === null) fail("the file must contain an object");
|
|
@@ -56,6 +62,13 @@ function parseMachine(value) {
|
|
|
56
62
|
}
|
|
57
63
|
};
|
|
58
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* ironSetting(machine, "2")?.label; // "••"
|
|
69
|
+
* ironSetting(machine, "nope"); // undefined
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
59
72
|
function ironSetting(machine, key) {
|
|
60
73
|
return machine.iron.settings.find((setting) => setting.key === key);
|
|
61
74
|
}
|
|
@@ -64,6 +77,11 @@ function ironSetting(machine, key) {
|
|
|
64
77
|
*
|
|
65
78
|
* There is no key for "do not iron". That is the `ironing` column's job, and
|
|
66
79
|
* two places to say the same thing is two places to disagree.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* ironSettingKeys(machine); // ["min", "1", "2", "3"]
|
|
84
|
+
* ```
|
|
67
85
|
*/
|
|
68
86
|
function ironSettingKeys(machine) {
|
|
69
87
|
return machine.iron.settings.map((setting) => setting.key);
|
|
@@ -72,6 +90,12 @@ function ironSettingKeys(machine) {
|
|
|
72
90
|
* `40` becomes `40°`; `cold` stays `cold`. The machine file is free to use
|
|
73
91
|
* whatever word its display shows for the cold wash, so the degree sign is
|
|
74
92
|
* decided by whether the value is a number rather than by a list of exceptions.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* formatTemperature("40"); // "40°"
|
|
97
|
+
* formatTemperature("cold"); // "cold"
|
|
98
|
+
* ```
|
|
75
99
|
*/
|
|
76
100
|
function formatTemperature(value) {
|
|
77
101
|
return /^\d+$/.test(value) ? `${value}°` : value;
|
|
@@ -102,6 +126,12 @@ const mixTags = [
|
|
|
102
126
|
* Usually one figure. Piles sharing a load agree on every setting, so they
|
|
103
127
|
* ought to agree on this too — but the chart is data somebody types, and
|
|
104
128
|
* printing both is more honest than picking the first one and hoping.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* durationsOf([pile, pile]); // "~2:00"
|
|
133
|
+
* durationsOf([pile, { ...pile, duration: "~1:10" }]); // "~2:00 / ~1:10"
|
|
134
|
+
* ```
|
|
105
135
|
*/
|
|
106
136
|
function durationsOf(group) {
|
|
107
137
|
return [...new Set(group.map((item) => item.duration).filter((value) => value !== ""))].join(" / ");
|
|
@@ -175,6 +205,11 @@ function boolean(row, column, value) {
|
|
|
175
205
|
* programme name fails here rather than producing a PDF that tells you to turn
|
|
176
206
|
* the dial to a position that does not exist — and so does a chart written for
|
|
177
207
|
* a different machine than the one you passed.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const instructions = instructionsFromRows(JSON.parse(jsonFromStorage), machine);
|
|
212
|
+
* ```
|
|
178
213
|
*/
|
|
179
214
|
function instructionsFromRows(rows, machine) {
|
|
180
215
|
const { washer } = machine;
|
|
@@ -211,7 +246,14 @@ function instructionsFromRows(rows, machine) {
|
|
|
211
246
|
};
|
|
212
247
|
});
|
|
213
248
|
}
|
|
214
|
-
/**
|
|
249
|
+
/**
|
|
250
|
+
* The reverse of `instructionsFromRows` — what a JSON export writes out.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* const rows = rowsFromInstructions(instructions);
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
215
257
|
function rowsFromInstructions(instructions) {
|
|
216
258
|
return instructions.map((instruction) => ({
|
|
217
259
|
clothing_type: instruction.clothingType,
|
|
@@ -235,11 +277,23 @@ function rowsFromInstructions(instructions) {
|
|
|
235
277
|
* The JSON interchange format for a chart — the same row shape
|
|
236
278
|
* a chart's JSON Schema describes, so a file written here validates against
|
|
237
279
|
* it exactly as a CSV does.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* const json = chartToJson(instructions);
|
|
284
|
+
* ```
|
|
238
285
|
*/
|
|
239
286
|
function chartToJson(instructions) {
|
|
240
287
|
return `${JSON.stringify(rowsFromInstructions(instructions), null, 2)}\n`;
|
|
241
288
|
}
|
|
242
|
-
/**
|
|
289
|
+
/**
|
|
290
|
+
* The other half of `chartToJson`. Throws the same errors `parseInstructions` does.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```ts
|
|
294
|
+
* const instructions = chartFromJson(jsonFromStorage, machine);
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
243
297
|
function chartFromJson(source, machine) {
|
|
244
298
|
let rows;
|
|
245
299
|
try {
|
|
@@ -253,10 +307,25 @@ function chartFromJson(source, machine) {
|
|
|
253
307
|
//#endregion
|
|
254
308
|
//#region src/config.ts
|
|
255
309
|
/**
|
|
310
|
+
* Where `configToJson` points editors at the real JSON Schema (generated
|
|
311
|
+
* from the `Config` type — see `schema/config.schema.json` and `bun run
|
|
312
|
+
* schema`). Unpinned to the package's `latest` npm tag rather than the
|
|
313
|
+
* running version, matching how most `$schema` URLs work: close enough,
|
|
314
|
+
* without needing a build-time read of this package's own `package.json`.
|
|
315
|
+
*/
|
|
316
|
+
const CONFIG_SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@washy-washy/core/schema/config.schema.json";
|
|
317
|
+
/**
|
|
256
318
|
* Validates a `{ machine, chart }` object, checking the chart against the
|
|
257
319
|
* machine it's embedded with — never a different one. Every failure names
|
|
258
320
|
* which half is wrong, same as `parseMachine` and `instructionsFromRows` do
|
|
259
321
|
* on their own.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* const config = parseConfig(JSON.parse(configFileContents));
|
|
326
|
+
* config.machine.washer.name; // "Generic front loader"
|
|
327
|
+
* config.chart[0].clothingType; // "Dark"
|
|
328
|
+
* ```
|
|
260
329
|
*/
|
|
261
330
|
function parseConfig(value) {
|
|
262
331
|
if (typeof value !== "object" || value === null) throw new Error("config: the file must contain an object");
|
|
@@ -270,15 +339,34 @@ function parseConfig(value) {
|
|
|
270
339
|
chart: instructionsFromRows(raw.chart, machine)
|
|
271
340
|
};
|
|
272
341
|
}
|
|
273
|
-
/**
|
|
342
|
+
/**
|
|
343
|
+
* The reverse of `parseConfig` — what a JSON export writes out. Leads with a
|
|
344
|
+
* `$schema` key so an editor that reads it (VS Code among them) validates
|
|
345
|
+
* and autocompletes the file without the person editing it doing anything.
|
|
346
|
+
* `parseConfig` ignores the key on the way back in — it never asks for
|
|
347
|
+
* anything beyond `machine` and `chart`.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* const json = configToJson(config);
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
274
354
|
function configToJson(config) {
|
|
275
355
|
const rows = {
|
|
356
|
+
$schema: CONFIG_SCHEMA_URL,
|
|
276
357
|
machine: config.machine,
|
|
277
358
|
chart: rowsFromInstructions(config.chart)
|
|
278
359
|
};
|
|
279
360
|
return `${JSON.stringify(rows, null, 2)}\n`;
|
|
280
361
|
}
|
|
281
|
-
/**
|
|
362
|
+
/**
|
|
363
|
+
* The other half of `configToJson`. Throws the same errors `parseConfig` does.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```ts
|
|
367
|
+
* const config = configFromJson(configFileContents);
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
282
370
|
function configFromJson(source) {
|
|
283
371
|
let value;
|
|
284
372
|
try {
|
|
@@ -316,6 +404,12 @@ function compatibleColours(a, b) {
|
|
|
316
404
|
* The order matters: the reason reported is the one you would want to hear
|
|
317
405
|
* first. "Wash it alone" beats "the spin speed differs", because changing the
|
|
318
406
|
* spin speed would not help.
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* mixBlocker(towels, socks); // "lint" — towels shed onto everything else
|
|
411
|
+
* mixBlocker(socks, socks2); // null — nothing stops them sharing a drum
|
|
412
|
+
* ```
|
|
319
413
|
*/
|
|
320
414
|
function mixBlocker(a, b) {
|
|
321
415
|
if (a.mixTags.includes("solo") || b.mixTags.includes("solo")) return "solo";
|
|
@@ -324,10 +418,23 @@ function mixBlocker(a, b) {
|
|
|
324
418
|
if (!sameSettings(a, b)) return "settings";
|
|
325
419
|
return null;
|
|
326
420
|
}
|
|
421
|
+
/**
|
|
422
|
+
* @example
|
|
423
|
+
* ```ts
|
|
424
|
+
* canMix(towels, socks); // false
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
327
427
|
function canMix(a, b) {
|
|
328
428
|
return mixBlocker(a, b) === null;
|
|
329
429
|
}
|
|
330
|
-
/**
|
|
430
|
+
/**
|
|
431
|
+
* Annotates each instruction with the other piles it may share a load with.
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```ts
|
|
435
|
+
* resolve(instructions)[0].mixesWith; // ["Socks", "Jeans"]
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
331
438
|
function resolve(instructions) {
|
|
332
439
|
return instructions.map((instruction) => ({
|
|
333
440
|
...instruction,
|
|
@@ -337,6 +444,11 @@ function resolve(instructions) {
|
|
|
337
444
|
/**
|
|
338
445
|
* Groups piles that can all be washed together — every member compatible with
|
|
339
446
|
* every other, not merely with the first one it met.
|
|
447
|
+
*
|
|
448
|
+
* @example
|
|
449
|
+
* ```ts
|
|
450
|
+
* loadGroups(instructions); // [[towels], [socks, jeans], [wool]]
|
|
451
|
+
* ```
|
|
340
452
|
*/
|
|
341
453
|
function loadGroups(instructions) {
|
|
342
454
|
const groups = [];
|
|
@@ -377,6 +489,12 @@ function washFingerprint(item) {
|
|
|
377
489
|
* Piles you set the machine and the iron up for identically. Every dial
|
|
378
490
|
* drawing on their cards would be the same drawing, so they get one card
|
|
379
491
|
* listing all the names.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```ts
|
|
495
|
+
* cardGroups(instructions).map((group) => group.map((item) => item.clothingType));
|
|
496
|
+
* // [["Socks", "Jeans"], ["Towels"]]
|
|
497
|
+
* ```
|
|
380
498
|
*/
|
|
381
499
|
function cardGroups(instructions) {
|
|
382
500
|
return groupBy(instructions, (item) => JSON.stringify([
|
|
@@ -389,6 +507,11 @@ function cardGroups(instructions) {
|
|
|
389
507
|
* The same, for a sheet with no iron on it. Dark, Black Socks and Denim each
|
|
390
508
|
* need their own card on the full chart only because they want three different
|
|
391
509
|
* thermostat positions; standing at the machine they are one wash.
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* ```ts
|
|
513
|
+
* washGroups(instructions); // merges piles cardGroups would have split on iron settings alone
|
|
514
|
+
* ```
|
|
392
515
|
*/
|
|
393
516
|
function washGroups(instructions) {
|
|
394
517
|
return groupBy(instructions, washFingerprint);
|
|
@@ -402,6 +525,11 @@ function washGroups(instructions) {
|
|
|
402
525
|
* and the piles are the list under it. `order` is `ironSettingKeys`; a pile you
|
|
403
526
|
* never iron has no position in it and sorts last, which is right — it is the
|
|
404
527
|
* pile you never pick up.
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* ```ts
|
|
531
|
+
* ironGroups(instructions, ironSettingKeys(machine));
|
|
532
|
+
* ```
|
|
405
533
|
*/
|
|
406
534
|
function ironGroups(instructions, order) {
|
|
407
535
|
const rank = (setting) => {
|
|
@@ -411,6 +539,6 @@ function ironGroups(instructions, order) {
|
|
|
411
539
|
return groupBy(instructions, (item) => item.ironSetting).sort((a, b) => rank(a[0].ironSetting) - rank(b[0].ironSetting));
|
|
412
540
|
}
|
|
413
541
|
//#endregion
|
|
414
|
-
export {
|
|
542
|
+
export { variants as C, parseMachine as D, ironSettingKeys as E, mixTags as S, ironSetting as T, chartToJson as _, ironGroups as a, colourGroups as b, resolve as c, configFromJson as d, configToJson as f, chartFromJson as g, RowError as h, cardGroups as i, washGroups as l, COLUMNS as m, blockerLegend as n, loadGroups as o, parseConfig as p, canMix as r, mixBlocker as s, blockerCode as t, CONFIG_SCHEMA_URL as u, instructionsFromRows as v, formatTemperature as w, durationsOf as x, rowsFromInstructions as y };
|
|
415
543
|
|
|
416
|
-
//# sourceMappingURL=mixing-
|
|
544
|
+
//# sourceMappingURL=mixing-DHXHkb3X.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixing-DHXHkb3X.mjs","names":[],"sources":["../src/machine.ts","../src/types.ts","../src/rows.ts","../src/config.ts","../src/mixing.ts"],"sourcesContent":["/**\n * The appliances a chart is drawn for, as data rather than code.\n *\n * Everything the PDFs render — dial angles, which chips exist, what a valid CSV\n * value is — comes from a machine file, so pointing this at a different washing\n * machine is editing JSON rather than editing TypeScript. The labels in that\n * file are copied off the fascia in whatever language it is printed in, and\n * nothing here ever translates them: a chart that says \"Cottons\" when the dial\n * says \"Katoen\" is worse than no chart, because you have to translate it back\n * while standing in front of the machine.\n */\n\nexport interface Washer {\n name: string;\n capacity: string;\n /** Dial labels in physical order from twelve o'clock, clockwise. Index is the angle. */\n programs: string[];\n temperatures: string[];\n spins: string[];\n options: string[];\n}\n\nexport interface IronSetting {\n key: string;\n dots: string;\n label: string;\n detail: string;\n steam: boolean;\n}\n\nexport interface Iron {\n name: string;\n /** Thermostat positions in order, coolest first. */\n settings: IronSetting[];\n}\n\nexport interface Machine {\n washer: Washer;\n iron: Iron;\n}\n\nfunction fail(what: string): never {\n throw new Error(`machine: ${what}`);\n}\n\nfunction stringList(value: unknown, field: string, minimum: number): string[] {\n if (!Array.isArray(value) || value.some((entry) => typeof entry !== \"string\" || entry === \"\")) {\n fail(`${field} must be a list of non-empty strings`);\n }\n const list = value as string[];\n if (list.length < minimum)\n fail(`${field} needs at least ${minimum} entries, found ${list.length}`);\n if (new Set(list).size !== list.length) fail(`${field} repeats a value`);\n return list;\n}\n\nfunction text(value: unknown, field: string, fallback?: string): string {\n if (typeof value === \"string\" && value !== \"\") return value;\n if (fallback !== undefined) return fallback;\n return fail(`${field} must be a non-empty string`);\n}\n\nfunction parseIronSetting(value: unknown, index: number): IronSetting {\n if (typeof value !== \"object\" || value === null)\n fail(`iron.settings[${index}] must be an object`);\n const raw = value as Record<string, unknown>;\n const key = text(raw.key, `iron.settings[${index}].key`);\n return {\n key,\n dots: typeof raw.dots === \"string\" ? raw.dots : \"\",\n label: text(raw.label, `iron.settings[${index}].label`),\n detail: text(raw.detail, `iron.settings[${index}].detail`, \"\"),\n steam: raw.steam === true,\n };\n}\n\n/**\n * Checks a parsed machine file and hands back something the renderer can use.\n * Every failure names the field, because the fix is always an edit to that\n * line of JSON.\n *\n * @example\n * ```ts\n * const machine = parseMachine(JSON.parse(machineFileContents));\n * machine.washer.programs; // [\"Off\", \"Cottons\", \"Wool\", ...]\n * ```\n */\nexport function parseMachine(value: unknown): Machine {\n if (typeof value !== \"object\" || value === null) fail(\"the file must contain an object\");\n const raw = value as Record<string, unknown>;\n\n if (typeof raw.washer !== \"object\" || raw.washer === null) fail(\"washer is missing\");\n if (typeof raw.iron !== \"object\" || raw.iron === null) fail(\"iron is missing\");\n\n const washerRaw = raw.washer as Record<string, unknown>;\n const ironRaw = raw.iron as Record<string, unknown>;\n\n const settings = Array.isArray(ironRaw.settings)\n ? ironRaw.settings\n : fail(\"iron.settings is missing\");\n if (settings.length < 2) fail(\"iron.settings needs at least 2 positions to draw a ring\");\n\n const keys = settings.map((setting, index) => parseIronSetting(setting, index));\n if (new Set(keys.map((setting) => setting.key)).size !== keys.length) {\n fail(\"iron.settings repeats a key\");\n }\n\n return {\n washer: {\n name: text(washerRaw.name, \"washer.name\"),\n capacity: text(washerRaw.capacity, \"washer.capacity\", \"\"),\n programs: stringList(washerRaw.programs, \"washer.programs\", 2),\n temperatures: stringList(washerRaw.temperatures, \"washer.temperatures\", 1),\n spins: stringList(washerRaw.spins, \"washer.spins\", 1),\n options: stringList(washerRaw.options ?? [], \"washer.options\", 0),\n },\n iron: {\n name: text(ironRaw.name, \"iron.name\"),\n settings: keys,\n },\n };\n}\n\n/**\n * @example\n * ```ts\n * ironSetting(machine, \"2\")?.label; // \"••\"\n * ironSetting(machine, \"nope\"); // undefined\n * ```\n */\nexport function ironSetting(machine: Machine, key: string): IronSetting | undefined {\n return machine.iron.settings.find((setting) => setting.key === key);\n}\n\n/**\n * The keys a row may write in `iron_setting`, coolest first.\n *\n * There is no key for \"do not iron\". That is the `ironing` column's job, and\n * two places to say the same thing is two places to disagree.\n *\n * @example\n * ```ts\n * ironSettingKeys(machine); // [\"min\", \"1\", \"2\", \"3\"]\n * ```\n */\nexport function ironSettingKeys(machine: Machine): string[] {\n return machine.iron.settings.map((setting) => setting.key);\n}\n\n/**\n * `40` becomes `40°`; `cold` stays `cold`. The machine file is free to use\n * whatever word its display shows for the cold wash, so the degree sign is\n * decided by whether the value is a number rather than by a list of exceptions.\n *\n * @example\n * ```ts\n * formatTemperature(\"40\"); // \"40°\"\n * formatTemperature(\"cold\"); // \"cold\"\n * ```\n */\nexport function formatTemperature(value: string): string {\n return /^\\d+$/.test(value) ? `${value}°` : value;\n}\n","/** Which pile a garment belongs to on colour grounds. `any` mixes with all. */\nexport const colourGroups = [\"white\", \"colour\", \"dark\", \"sport\", \"any\"] as const;\nexport type ColourGroup = (typeof colourGroups)[number];\n\n/**\n * Reasons two piles might not belong together even when the machine settings\n * agree. See `canMix` in `mixing.ts` for how each one is applied.\n */\nexport const mixTags = [\"lint-shedder\", \"lint-magnet\", \"dye-bleeder\", \"solo\"] as const;\nexport type MixTag = (typeof mixTags)[number];\n\n/**\n * One CSV row: everything needed to wash, iron and dry one pile of laundry.\n *\n * The machine-facing fields are plain strings rather than unions, because what\n * counts as valid depends on the machine file you point this at. `csv.ts`\n * checks each of them against that machine as it parses, so nothing downstream\n * has to wonder whether a programme name exists.\n */\nexport interface Instruction {\n clothingType: string;\n detergent: string;\n fabricSoftener: boolean;\n temperature: string;\n spin: string;\n duration: string;\n program: string;\n options: string[];\n /** Whether this pile gets ironed at all. */\n ironing: boolean;\n /**\n * How to iron it, or why you don't. Free prose and often empty, because most\n * of what there is to say about a pile nobody irons is already said by\n * `ironing` being false.\n */\n ironingNotes: string;\n /** Thermostat position. Empty when `ironing` is false. */\n ironSetting: string;\n drying: string;\n colourGroup: ColourGroup;\n mixTags: MixTag[];\n notes: string;\n}\n\n/** An instruction plus the other piles it may share a drum with. */\nexport interface ResolvedInstruction extends Instruction {\n mixesWith: string[];\n}\n\n/**\n * How long a card or a load is going to tie the machine up.\n *\n * Usually one figure. Piles sharing a load agree on every setting, so they\n * ought to agree on this too — but the chart is data somebody types, and\n * printing both is more honest than picking the first one and hoping.\n *\n * @example\n * ```ts\n * durationsOf([pile, pile]); // \"~2:00\"\n * durationsOf([pile, { ...pile, duration: \"~1:10\" }]); // \"~2:00 / ~1:10\"\n * ```\n */\nexport function durationsOf(group: Instruction[]): string {\n return [...new Set(group.map((item) => item.duration).filter((value) => value !== \"\"))].join(\n \" / \",\n );\n}\n\n/**\n * Which sheet to draw.\n *\n * `full` is the whole chart. The other two are the same chart cut where the\n * work is: washing happens in front of the machine on a Sunday morning, ironing\n * happens at a board on a Wednesday evening, and neither job wants to read past\n * the other's advice to find its own.\n */\nexport const variants = [\"full\", \"wash\", \"iron\"] as const;\nexport type Variant = (typeof variants)[number];\n","import { ironSettingKeys, type Machine } from \"./machine\";\nimport type { ColourGroup, Instruction, MixTag } from \"./types\";\nimport { colourGroups, mixTags } from \"./types\";\n\nexport const COLUMNS = [\n \"clothing_type\",\n \"detergent\",\n \"fabric_softener\",\n \"temperature\",\n \"spin\",\n \"duration\",\n \"program\",\n \"options\",\n \"ironing\",\n \"ironing_notes\",\n \"iron_setting\",\n \"drying\",\n \"colour_group\",\n \"mix_tags\",\n \"notes\",\n] as const;\n\n/** One row, keyed the same way as a CSV column and the chart's JSON Schema. */\nexport type Row = Record<(typeof COLUMNS)[number], string>;\n\nexport class RowError extends Error {\n constructor(row: number, column: string, message: string) {\n super(`row ${row}, column \"${column}\": ${message}`);\n this.name = \"RowError\";\n }\n}\n\n/** `a|b|c` -> `[\"a\", \"b\", \"c\"]`, tolerating stray whitespace and empties. */\nfunction splitList(value: string): string[] {\n return value\n .split(\"|\")\n .map((part) => part.trim())\n .filter((part) => part.length > 0);\n}\n\nfunction oneOf<T extends string>(\n row: number,\n column: string,\n value: string,\n allowed: readonly T[],\n): T {\n if (!(allowed as readonly string[]).includes(value)) {\n throw new RowError(row, column, `\"${value}\" is not one of ${allowed.join(\", \")}`);\n }\n return value as T;\n}\n\nfunction boolean(row: number, column: string, value: string): boolean {\n const normalised = value.trim().toLowerCase();\n if ([\"yes\", \"y\", \"true\", \"1\"].includes(normalised)) return true;\n if ([\"no\", \"n\", \"false\", \"0\"].includes(normalised)) return false;\n throw new RowError(row, column, `\"${value}\" is not a yes/no value`);\n}\n\n/**\n * Checks rows shaped like the chart's schema — the same shape a CSV parses\n * into, or a JSON file round-tripped through `rowsFromInstructions` — against\n * what the appliances in the machine file can actually be set to. A typo in a\n * programme name fails here rather than producing a PDF that tells you to turn\n * the dial to a position that does not exist — and so does a chart written for\n * a different machine than the one you passed.\n *\n * @example\n * ```ts\n * const instructions = instructionsFromRows(JSON.parse(jsonFromStorage), machine);\n * ```\n */\nexport function instructionsFromRows(\n rows: Record<string, string>[],\n machine: Machine,\n): Instruction[] {\n const { washer } = machine;\n\n if (rows.length === 0) throw new Error(\"the chart has no rows\");\n\n const header = Object.keys(rows[0] as Record<string, string>);\n const missing = COLUMNS.filter((column) => !header.includes(column));\n if (missing.length > 0) {\n throw new Error(`the chart is missing column(s): ${missing.join(\", \")}`);\n }\n\n return rows.map((record, index) => {\n // +2: one for the header row, one because humans count from 1. Kept even\n // for a JSON source, so an error message reads the same regardless of\n // which format the chart came from.\n const row = index + 2;\n\n const clothingType = (record.clothing_type ?? \"\").trim();\n if (clothingType === \"\") throw new RowError(row, \"clothing_type\", \"must not be empty\");\n\n const options = splitList(record.options ?? \"\").map((option) =>\n oneOf(row, \"options\", option, washer.options),\n );\n\n const tags = splitList(record.mix_tags ?? \"\").map((tag) =>\n oneOf<MixTag>(row, \"mix_tags\", tag, mixTags),\n );\n\n // `ironing` decides whether there is a thermostat position at all, so the\n // two are checked together: a pile you never iron has nowhere to point the\n // dial, and a pile you do iron has to say where.\n const ironing = boolean(row, \"ironing\", record.ironing ?? \"\");\n const rawSetting = (record.iron_setting ?? \"\").trim();\n if (!ironing && rawSetting !== \"\") {\n throw new RowError(\n row,\n \"iron_setting\",\n `must be empty when ironing is no, found \"${rawSetting}\"`,\n );\n }\n const ironSetting = ironing\n ? oneOf(row, \"iron_setting\", rawSetting, ironSettingKeys(machine))\n : \"\";\n\n return {\n clothingType,\n detergent: record.detergent ?? \"\",\n fabricSoftener: boolean(row, \"fabric_softener\", record.fabric_softener ?? \"\"),\n temperature: oneOf(row, \"temperature\", record.temperature ?? \"\", washer.temperatures),\n spin: oneOf(row, \"spin\", record.spin ?? \"\", washer.spins),\n duration: record.duration ?? \"\",\n program: oneOf(row, \"program\", record.program ?? \"\", washer.programs),\n options,\n ironing,\n ironingNotes: record.ironing_notes ?? \"\",\n ironSetting,\n drying: record.drying ?? \"\",\n colourGroup: oneOf<ColourGroup>(row, \"colour_group\", record.colour_group ?? \"\", colourGroups),\n mixTags: tags,\n notes: record.notes ?? \"\",\n };\n });\n}\n\n/**\n * The reverse of `instructionsFromRows` — what a JSON export writes out.\n *\n * @example\n * ```ts\n * const rows = rowsFromInstructions(instructions);\n * ```\n */\nexport function rowsFromInstructions(instructions: Instruction[]): Row[] {\n return instructions.map((instruction) => ({\n clothing_type: instruction.clothingType,\n detergent: instruction.detergent,\n fabric_softener: instruction.fabricSoftener ? \"yes\" : \"no\",\n temperature: instruction.temperature,\n spin: instruction.spin,\n duration: instruction.duration,\n program: instruction.program,\n options: instruction.options.join(\"|\"),\n ironing: instruction.ironing ? \"yes\" : \"no\",\n ironing_notes: instruction.ironingNotes,\n iron_setting: instruction.ironSetting,\n drying: instruction.drying,\n colour_group: instruction.colourGroup,\n mix_tags: instruction.mixTags.join(\"|\"),\n notes: instruction.notes,\n }));\n}\n\n/**\n * The JSON interchange format for a chart — the same row shape\n * a chart's JSON Schema describes, so a file written here validates against\n * it exactly as a CSV does.\n *\n * @example\n * ```ts\n * const json = chartToJson(instructions);\n * ```\n */\nexport function chartToJson(instructions: Instruction[]): string {\n return `${JSON.stringify(rowsFromInstructions(instructions), null, 2)}\\n`;\n}\n\n/**\n * The other half of `chartToJson`. Throws the same errors `parseInstructions` does.\n *\n * @example\n * ```ts\n * const instructions = chartFromJson(jsonFromStorage, machine);\n * ```\n */\nexport function chartFromJson(source: string, machine: Machine): Instruction[] {\n let rows: unknown;\n try {\n rows = JSON.parse(source);\n } catch (error) {\n throw new Error(`not valid JSON: ${error instanceof Error ? error.message : error}`);\n }\n if (!Array.isArray(rows)) throw new Error(\"the chart must be a JSON array of rows\");\n return instructionsFromRows(rows as Record<string, string>[], machine);\n}\n","import { type Machine, parseMachine } from \"./machine\";\nimport { instructionsFromRows, rowsFromInstructions } from \"./rows\";\nimport type { Instruction } from \"./types\";\n\n/**\n * Where `configToJson` points editors at the real JSON Schema (generated\n * from the `Config` type — see `schema/config.schema.json` and `bun run\n * schema`). Unpinned to the package's `latest` npm tag rather than the\n * running version, matching how most `$schema` URLs work: close enough,\n * without needing a build-time read of this package's own `package.json`.\n */\nexport const CONFIG_SCHEMA_URL =\n \"https://cdn.jsdelivr.net/npm/@washy-washy/core/schema/config.schema.json\";\n\n/**\n * The washing machine and the chart that describes it, in one place. Both\n * halves are exactly what `parseMachine`/`instructionsFromRows` already\n * produce — this is a wrapper around the pair, not a third shape.\n */\nexport interface Config {\n machine: Machine;\n chart: Instruction[];\n}\n\n/**\n * Validates a `{ machine, chart }` object, checking the chart against the\n * machine it's embedded with — never a different one. Every failure names\n * which half is wrong, same as `parseMachine` and `instructionsFromRows` do\n * on their own.\n *\n * @example\n * ```ts\n * const config = parseConfig(JSON.parse(configFileContents));\n * config.machine.washer.name; // \"Generic front loader\"\n * config.chart[0].clothingType; // \"Dark\"\n * ```\n */\nexport function parseConfig(value: unknown): Config {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"config: the file must contain an object\");\n }\n const raw = value as Record<string, unknown>;\n\n if (!(\"machine\" in raw)) throw new Error(\"config: machine is missing\");\n if (!(\"chart\" in raw)) throw new Error(\"config: chart is missing\");\n\n const machine = parseMachine(raw.machine);\n\n if (!Array.isArray(raw.chart)) throw new Error(\"config: chart must be an array of rows\");\n const chart = instructionsFromRows(raw.chart as Record<string, string>[], machine);\n\n return { machine, chart };\n}\n\n/**\n * The reverse of `parseConfig` — what a JSON export writes out. Leads with a\n * `$schema` key so an editor that reads it (VS Code among them) validates\n * and autocompletes the file without the person editing it doing anything.\n * `parseConfig` ignores the key on the way back in — it never asks for\n * anything beyond `machine` and `chart`.\n *\n * @example\n * ```ts\n * const json = configToJson(config);\n * ```\n */\nexport function configToJson(config: Config): string {\n const rows = {\n $schema: CONFIG_SCHEMA_URL,\n machine: config.machine,\n chart: rowsFromInstructions(config.chart),\n };\n return `${JSON.stringify(rows, null, 2)}\\n`;\n}\n\n/**\n * The other half of `configToJson`. Throws the same errors `parseConfig` does.\n *\n * @example\n * ```ts\n * const config = configFromJson(configFileContents);\n * ```\n */\nexport function configFromJson(source: string): Config {\n let value: unknown;\n try {\n value = JSON.parse(source);\n } catch (error) {\n throw new Error(`config: not valid JSON: ${error instanceof Error ? error.message : error}`);\n }\n return parseConfig(value);\n}\n","import type { Instruction, ResolvedInstruction } from \"./types\";\n\n/** Why two piles cannot share a drum. `null` means they can. */\nexport type Blocker = \"solo\" | \"settings\" | \"colour\" | \"lint\";\n\nexport const blockerLegend: Record<Blocker, string> = {\n solo: \"Wash on its own\",\n settings: \"Different programme, temperature, spin or options\",\n colour: \"Colours would run into each other\",\n lint: \"One sheds lint onto the other\",\n};\n\n/** Short codes used in the compatibility matrix, so a cell stays one glyph. */\nexport const blockerCode: Record<Blocker, string> = {\n solo: \"S\",\n settings: \"P\",\n colour: \"C\",\n lint: \"L\",\n};\n\nfunction sameSettings(a: Instruction, b: Instruction): boolean {\n return (\n a.program === b.program &&\n a.temperature === b.temperature &&\n a.spin === b.spin &&\n a.options.length === b.options.length &&\n a.options.every((option) => b.options.includes(option))\n );\n}\n\nfunction compatibleColours(a: Instruction, b: Instruction): boolean {\n if (a.colourGroup === \"any\" || b.colourGroup === \"any\") return true;\n return a.colourGroup === b.colourGroup;\n}\n\n/**\n * Decides whether two piles can go in the drum together, and if not, why.\n *\n * The order matters: the reason reported is the one you would want to hear\n * first. \"Wash it alone\" beats \"the spin speed differs\", because changing the\n * spin speed would not help.\n *\n * @example\n * ```ts\n * mixBlocker(towels, socks); // \"lint\" — towels shed onto everything else\n * mixBlocker(socks, socks2); // null — nothing stops them sharing a drum\n * ```\n */\nexport function mixBlocker(a: Instruction, b: Instruction): Blocker | null {\n if (a.mixTags.includes(\"solo\") || b.mixTags.includes(\"solo\")) return \"solo\";\n\n // Terry sheds lint over everything, so towels only ever go with towels.\n const shedders = [a, b].filter((item) => item.mixTags.includes(\"lint-shedder\"));\n if (shedders.length === 1) return \"lint\";\n\n if (!compatibleColours(a, b)) return \"colour\";\n if (!sameSettings(a, b)) return \"settings\";\n return null;\n}\n\n/**\n * @example\n * ```ts\n * canMix(towels, socks); // false\n * ```\n */\nexport function canMix(a: Instruction, b: Instruction): boolean {\n return mixBlocker(a, b) === null;\n}\n\n/**\n * Annotates each instruction with the other piles it may share a load with.\n *\n * @example\n * ```ts\n * resolve(instructions)[0].mixesWith; // [\"Socks\", \"Jeans\"]\n * ```\n */\nexport function resolve(instructions: Instruction[]): ResolvedInstruction[] {\n return instructions.map((instruction) => ({\n ...instruction,\n mixesWith: instructions\n .filter((other) => other !== instruction && canMix(instruction, other))\n .map((other) => other.clothingType),\n }));\n}\n\n/**\n * Groups piles that can all be washed together — every member compatible with\n * every other, not merely with the first one it met.\n *\n * @example\n * ```ts\n * loadGroups(instructions); // [[towels], [socks, jeans], [wool]]\n * ```\n */\nexport function loadGroups<T extends Instruction>(instructions: T[]): T[][] {\n const groups: T[][] = [];\n for (const instruction of instructions) {\n const home = groups.find((group) => group.every((member) => canMix(member, instruction)));\n if (home) home.push(instruction);\n else groups.push([instruction]);\n }\n return groups;\n}\n\nfunction groupBy<T>(items: T[], key: (item: T) => string): T[][] {\n const groups = new Map<string, T[]>();\n for (const item of items) {\n const existing = groups.get(key(item));\n if (existing) existing.push(item);\n else groups.set(key(item), [item]);\n }\n return [...groups.values()];\n}\n\n/**\n * Everything you physically set on the washing machine: the programme, what\n * the display reads, which buttons are lit, and whether softener goes in.\n *\n * Deliberately *not* the prose. Two piles can want the same five settings and\n * still want different detergent or a different drying rack, and those the card\n * lists per pile rather than splitting into two near-identical cards.\n */\nfunction washFingerprint(item: Instruction): string {\n return JSON.stringify([\n item.program,\n item.temperature,\n item.spin,\n [...item.options].sort(),\n item.fabricSoftener,\n ]);\n}\n\n/**\n * Piles you set the machine and the iron up for identically. Every dial\n * drawing on their cards would be the same drawing, so they get one card\n * listing all the names.\n *\n * @example\n * ```ts\n * cardGroups(instructions).map((group) => group.map((item) => item.clothingType));\n * // [[\"Socks\", \"Jeans\"], [\"Towels\"]]\n * ```\n */\nexport function cardGroups<T extends Instruction>(instructions: T[]): T[][] {\n return groupBy(instructions, (item) =>\n JSON.stringify([washFingerprint(item), item.ironing, item.ironSetting]),\n );\n}\n\n/**\n * The same, for a sheet with no iron on it. Dark, Black Socks and Denim each\n * need their own card on the full chart only because they want three different\n * thermostat positions; standing at the machine they are one wash.\n *\n * @example\n * ```ts\n * washGroups(instructions); // merges piles cardGroups would have split on iron settings alone\n * ```\n */\nexport function washGroups<T extends Instruction>(instructions: T[]): T[][] {\n return groupBy(instructions, washFingerprint);\n}\n\n/**\n * Piles by where the iron's thermostat points, coolest first.\n *\n * An ironing sheet is read the other way round from a washing one. You do not\n * fetch a pile and look up its setting — you set the iron once and work through\n * everything that goes at that heat, so the thermostat position is the heading\n * and the piles are the list under it. `order` is `ironSettingKeys`; a pile you\n * never iron has no position in it and sorts last, which is right — it is the\n * pile you never pick up.\n *\n * @example\n * ```ts\n * ironGroups(instructions, ironSettingKeys(machine));\n * ```\n */\nexport function ironGroups<T extends Instruction>(\n instructions: T[],\n order: readonly string[],\n): T[][] {\n const rank = (setting: string) => {\n const at = order.indexOf(setting);\n return at < 0 ? order.length : at;\n };\n return groupBy(instructions, (item) => item.ironSetting).sort(\n (a, b) => rank((a[0] as T).ironSetting) - rank((b[0] as T).ironSetting),\n );\n}\n"],"mappings":";AAyCA,SAAS,KAAK,MAAqB;CACjC,MAAM,IAAI,MAAM,YAAY,MAAM;AACpC;AAEA,SAAS,WAAW,OAAgB,OAAe,SAA2B;CAC5E,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,UAAU,OAAO,UAAU,YAAY,UAAU,EAAE,GAC1F,KAAK,GAAG,MAAM,qCAAqC;CAErD,MAAM,OAAO;CACb,IAAI,KAAK,SAAS,SAChB,KAAK,GAAG,MAAM,kBAAkB,QAAQ,kBAAkB,KAAK,QAAQ;CACzE,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,SAAS,KAAK,QAAQ,KAAK,GAAG,MAAM,iBAAiB;CACvE,OAAO;AACT;AAEA,SAAS,KAAK,OAAgB,OAAe,UAA2B;CACtE,IAAI,OAAO,UAAU,YAAY,UAAU,IAAI,OAAO;CACtD,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,OAAO,KAAK,GAAG,MAAM,4BAA4B;AACnD;AAEA,SAAS,iBAAiB,OAAgB,OAA4B;CACpE,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,KAAK,iBAAiB,MAAM,oBAAoB;CAClD,MAAM,MAAM;CAEZ,OAAO;EACL,KAFU,KAAK,IAAI,KAAK,iBAAiB,MAAM,MAE7C;EACF,MAAM,OAAO,IAAI,SAAS,WAAW,IAAI,OAAO;EAChD,OAAO,KAAK,IAAI,OAAO,iBAAiB,MAAM,QAAQ;EACtD,QAAQ,KAA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AI,UAAU,SAAS,KAAK,IAAI;OAC3B,OAAO,IAAI,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC;CACnC;CACA,OAAO,CAAC,GAAG,OAAO,OAAO,CAAC;AAC5B;;;;;;;;;AAUA,SAAS,gBAAgB,MAA2B;CAClD,OAAO,KAAK,UAAU;EACpB,KAAK;EACL,KAAK;EACL,KAAK;EACL,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,KAAK;EACvB,KAAK;CACP,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,WAAkC,cAA0B;CAC1E,OAAO,QAAQ,eAAe,SAC5B,KAAK,UAAU;EAAC,gBAAgB,IAAI;EAAG,KAAK;EAAS,KAAK;CAAW,CAAC,CACxE;AACF;;;;;;;;;;;AAYA,SAAgB,WAAkC,cAA0B;CAC1E,OAAO,QAAQ,cAAc,eAAe;AAC9C;;;;;;;;;;;;;;;;AAiBA,SAAgB,WACd,cACA,OACO;CACP,MAAM,QAAQ,YAAoB;EAChC,MAAM,KAAK,MAAM,QAAQ,OAAO;EAChC,OAAO,KAAK,IAAI,MAAM,SAAS;CACjC;CACA,OAAO,QAAQ,eAAe,SAAS,KAAK,WAAW,CAAC,CAAC,MACtD,GAAG,MAAM,KAAM,EAAE,EAAE,CAAO,WAAW,IAAI,KAAM,EAAE,EAAE,CAAO,WAAW,CACxE;AACF"}
|
|
@@ -39,20 +39,44 @@ interface Machine {
|
|
|
39
39
|
* Checks a parsed machine file and hands back something the renderer can use.
|
|
40
40
|
* Every failure names the field, because the fix is always an edit to that
|
|
41
41
|
* line of JSON.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const machine = parseMachine(JSON.parse(machineFileContents));
|
|
46
|
+
* machine.washer.programs; // ["Off", "Cottons", "Wool", ...]
|
|
47
|
+
* ```
|
|
42
48
|
*/
|
|
43
49
|
declare function parseMachine(value: unknown): Machine;
|
|
50
|
+
/**
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* ironSetting(machine, "2")?.label; // "••"
|
|
54
|
+
* ironSetting(machine, "nope"); // undefined
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
44
57
|
declare function ironSetting(machine: Machine, key: string): IronSetting | undefined;
|
|
45
58
|
/**
|
|
46
59
|
* The keys a row may write in `iron_setting`, coolest first.
|
|
47
60
|
*
|
|
48
61
|
* There is no key for "do not iron". That is the `ironing` column's job, and
|
|
49
62
|
* two places to say the same thing is two places to disagree.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* ironSettingKeys(machine); // ["min", "1", "2", "3"]
|
|
67
|
+
* ```
|
|
50
68
|
*/
|
|
51
69
|
declare function ironSettingKeys(machine: Machine): string[];
|
|
52
70
|
/**
|
|
53
71
|
* `40` becomes `40°`; `cold` stays `cold`. The machine file is free to use
|
|
54
72
|
* whatever word its display shows for the cold wash, so the degree sign is
|
|
55
73
|
* decided by whether the value is a number rather than by a list of exceptions.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* formatTemperature("40"); // "40°"
|
|
78
|
+
* formatTemperature("cold"); // "cold"
|
|
79
|
+
* ```
|
|
56
80
|
*/
|
|
57
81
|
declare function formatTemperature(value: string): string;
|
|
58
82
|
//#endregion
|
|
@@ -108,6 +132,12 @@ interface ResolvedInstruction extends Instruction {
|
|
|
108
132
|
* Usually one figure. Piles sharing a load agree on every setting, so they
|
|
109
133
|
* ought to agree on this too — but the chart is data somebody types, and
|
|
110
134
|
* printing both is more honest than picking the first one and hoping.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* durationsOf([pile, pile]); // "~2:00"
|
|
139
|
+
* durationsOf([pile, { ...pile, duration: "~1:10" }]); // "~2:00 / ~1:10"
|
|
140
|
+
* ```
|
|
111
141
|
*/
|
|
112
142
|
declare function durationsOf(group: Instruction[]): string;
|
|
113
143
|
/**
|
|
@@ -122,6 +152,14 @@ declare const variants: readonly ["full", "wash", "iron"];
|
|
|
122
152
|
type Variant = (typeof variants)[number];
|
|
123
153
|
//#endregion
|
|
124
154
|
//#region src/config.d.ts
|
|
155
|
+
/**
|
|
156
|
+
* Where `configToJson` points editors at the real JSON Schema (generated
|
|
157
|
+
* from the `Config` type — see `schema/config.schema.json` and `bun run
|
|
158
|
+
* schema`). Unpinned to the package's `latest` npm tag rather than the
|
|
159
|
+
* running version, matching how most `$schema` URLs work: close enough,
|
|
160
|
+
* without needing a build-time read of this package's own `package.json`.
|
|
161
|
+
*/
|
|
162
|
+
declare const CONFIG_SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@washy-washy/core/schema/config.schema.json";
|
|
125
163
|
/**
|
|
126
164
|
* The washing machine and the chart that describes it, in one place. Both
|
|
127
165
|
* halves are exactly what `parseMachine`/`instructionsFromRows` already
|
|
@@ -136,11 +174,36 @@ interface Config {
|
|
|
136
174
|
* machine it's embedded with — never a different one. Every failure names
|
|
137
175
|
* which half is wrong, same as `parseMachine` and `instructionsFromRows` do
|
|
138
176
|
* on their own.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const config = parseConfig(JSON.parse(configFileContents));
|
|
181
|
+
* config.machine.washer.name; // "Generic front loader"
|
|
182
|
+
* config.chart[0].clothingType; // "Dark"
|
|
183
|
+
* ```
|
|
139
184
|
*/
|
|
140
185
|
declare function parseConfig(value: unknown): Config;
|
|
141
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* The reverse of `parseConfig` — what a JSON export writes out. Leads with a
|
|
188
|
+
* `$schema` key so an editor that reads it (VS Code among them) validates
|
|
189
|
+
* and autocompletes the file without the person editing it doing anything.
|
|
190
|
+
* `parseConfig` ignores the key on the way back in — it never asks for
|
|
191
|
+
* anything beyond `machine` and `chart`.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const json = configToJson(config);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
142
198
|
declare function configToJson(config: Config): string;
|
|
143
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* The other half of `configToJson`. Throws the same errors `parseConfig` does.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* const config = configFromJson(configFileContents);
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
144
207
|
declare function configFromJson(source: string): Config;
|
|
145
208
|
//#endregion
|
|
146
209
|
//#region src/mixing.d.ts
|
|
@@ -155,26 +218,61 @@ declare const blockerCode: Record<Blocker, string>;
|
|
|
155
218
|
* The order matters: the reason reported is the one you would want to hear
|
|
156
219
|
* first. "Wash it alone" beats "the spin speed differs", because changing the
|
|
157
220
|
* spin speed would not help.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* mixBlocker(towels, socks); // "lint" — towels shed onto everything else
|
|
225
|
+
* mixBlocker(socks, socks2); // null — nothing stops them sharing a drum
|
|
226
|
+
* ```
|
|
158
227
|
*/
|
|
159
228
|
declare function mixBlocker(a: Instruction, b: Instruction): Blocker | null;
|
|
229
|
+
/**
|
|
230
|
+
* @example
|
|
231
|
+
* ```ts
|
|
232
|
+
* canMix(towels, socks); // false
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
160
235
|
declare function canMix(a: Instruction, b: Instruction): boolean;
|
|
161
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Annotates each instruction with the other piles it may share a load with.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* resolve(instructions)[0].mixesWith; // ["Socks", "Jeans"]
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
162
244
|
declare function resolve(instructions: Instruction[]): ResolvedInstruction[];
|
|
163
245
|
/**
|
|
164
246
|
* Groups piles that can all be washed together — every member compatible with
|
|
165
247
|
* every other, not merely with the first one it met.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```ts
|
|
251
|
+
* loadGroups(instructions); // [[towels], [socks, jeans], [wool]]
|
|
252
|
+
* ```
|
|
166
253
|
*/
|
|
167
254
|
declare function loadGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
168
255
|
/**
|
|
169
256
|
* Piles you set the machine and the iron up for identically. Every dial
|
|
170
257
|
* drawing on their cards would be the same drawing, so they get one card
|
|
171
258
|
* listing all the names.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* cardGroups(instructions).map((group) => group.map((item) => item.clothingType));
|
|
263
|
+
* // [["Socks", "Jeans"], ["Towels"]]
|
|
264
|
+
* ```
|
|
172
265
|
*/
|
|
173
266
|
declare function cardGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
174
267
|
/**
|
|
175
268
|
* The same, for a sheet with no iron on it. Dark, Black Socks and Denim each
|
|
176
269
|
* need their own card on the full chart only because they want three different
|
|
177
270
|
* thermostat positions; standing at the machine they are one wash.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* washGroups(instructions); // merges piles cardGroups would have split on iron settings alone
|
|
275
|
+
* ```
|
|
178
276
|
*/
|
|
179
277
|
declare function washGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
180
278
|
/**
|
|
@@ -186,6 +284,11 @@ declare function washGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
|
186
284
|
* and the piles are the list under it. `order` is `ironSettingKeys`; a pile you
|
|
187
285
|
* never iron has no position in it and sorts last, which is right — it is the
|
|
188
286
|
* pile you never pick up.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* ironGroups(instructions, ironSettingKeys(machine));
|
|
291
|
+
* ```
|
|
189
292
|
*/
|
|
190
293
|
declare function ironGroups<T extends Instruction>(instructions: T[], order: readonly string[]): T[][];
|
|
191
294
|
//#endregion
|
|
@@ -203,18 +306,42 @@ declare class RowError extends Error {
|
|
|
203
306
|
* programme name fails here rather than producing a PDF that tells you to turn
|
|
204
307
|
* the dial to a position that does not exist — and so does a chart written for
|
|
205
308
|
* a different machine than the one you passed.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```ts
|
|
312
|
+
* const instructions = instructionsFromRows(JSON.parse(jsonFromStorage), machine);
|
|
313
|
+
* ```
|
|
206
314
|
*/
|
|
207
315
|
declare function instructionsFromRows(rows: Record<string, string>[], machine: Machine): Instruction[];
|
|
208
|
-
/**
|
|
316
|
+
/**
|
|
317
|
+
* The reverse of `instructionsFromRows` — what a JSON export writes out.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* const rows = rowsFromInstructions(instructions);
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
209
324
|
declare function rowsFromInstructions(instructions: Instruction[]): Row[];
|
|
210
325
|
/**
|
|
211
326
|
* The JSON interchange format for a chart — the same row shape
|
|
212
327
|
* a chart's JSON Schema describes, so a file written here validates against
|
|
213
328
|
* it exactly as a CSV does.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```ts
|
|
332
|
+
* const json = chartToJson(instructions);
|
|
333
|
+
* ```
|
|
214
334
|
*/
|
|
215
335
|
declare function chartToJson(instructions: Instruction[]): string;
|
|
216
|
-
/**
|
|
336
|
+
/**
|
|
337
|
+
* The other half of `chartToJson`. Throws the same errors `parseInstructions` does.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* const instructions = chartFromJson(jsonFromStorage, machine);
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
217
344
|
declare function chartFromJson(source: string, machine: Machine): Instruction[];
|
|
218
345
|
//#endregion
|
|
219
|
-
export {
|
|
220
|
-
//# sourceMappingURL=rows-
|
|
346
|
+
export { mixTags as A, ColourGroup as C, Variant as D, ResolvedInstruction as E, Washer as F, formatTemperature as I, ironSetting as L, Iron as M, IronSetting as N, colourGroups as O, Machine as P, ironSettingKeys as R, parseConfig as S, MixTag as T, washGroups as _, chartToJson as a, configFromJson as b, Blocker as c, canMix as d, cardGroups as f, resolve as g, mixBlocker as h, chartFromJson as i, variants as j, durationsOf as k, blockerCode as l, loadGroups as m, Row as n, instructionsFromRows as o, ironGroups as p, RowError as r, rowsFromInstructions as s, COLUMNS as t, blockerLegend as u, CONFIG_SCHEMA_URL as v, Instruction as w, configToJson as x, Config as y, parseMachine as z };
|
|
347
|
+
//# sourceMappingURL=rows-BawMuBGc.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@washy-washy/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Chart parsing, mixing rules and machine validation for washy-washy — a laundry chart generator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"laundry",
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist",
|
|
30
|
+
"schema",
|
|
30
31
|
"README.md",
|
|
31
32
|
"LICENSE"
|
|
32
33
|
],
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "tsdown",
|
|
35
|
-
"check": "bun run lint && bun run lint:md && bun run lint:yaml && bun run lint:package-json && bun run lint:prose && bun run typecheck && bun test",
|
|
36
|
+
"check": "bun run lint && bun run lint:md && bun run lint:yaml && bun run lint:package-json && bun run lint:prose && bun run lint:schema && bun run typecheck && bun test",
|
|
37
|
+
"docs": "typedoc",
|
|
36
38
|
"format": "prettier --write .",
|
|
37
39
|
"lint": "biome check .",
|
|
38
40
|
"lint:fix": "biome check --write .",
|
|
@@ -40,9 +42,11 @@
|
|
|
40
42
|
"lint:package-json": "sort-package-json --check",
|
|
41
43
|
"lint:prose": ".tools/vale --glob='!{styles/**,CHANGELOG.md}' --minAlertLevel=error .",
|
|
42
44
|
"lint:prose:advice": ".tools/vale --glob='!{styles/**,CHANGELOG.md}' .",
|
|
45
|
+
"lint:schema": "bun run schema && git diff --exit-code schema/",
|
|
43
46
|
"lint:yaml": "prettier --check \"**/*.{yml,yaml}\"",
|
|
44
47
|
"prepare": "lefthook install",
|
|
45
48
|
"prose:sync": "bun run scripts/install-vale.ts && .tools/vale sync",
|
|
49
|
+
"schema": "ts-json-schema-generator --path src/config.ts --type Config --tsconfig tsconfig.json -o schema/config.schema.json && biome format --write schema/config.schema.json",
|
|
46
50
|
"test": "bun test",
|
|
47
51
|
"typecheck": "tsc --noEmit"
|
|
48
52
|
},
|
|
@@ -65,7 +69,9 @@
|
|
|
65
69
|
"prettier": "3.9.6",
|
|
66
70
|
"semantic-release": "25.0.9",
|
|
67
71
|
"sort-package-json": "4.0.0",
|
|
72
|
+
"ts-json-schema-generator": "2.9.0",
|
|
68
73
|
"tsdown": "0.22.14",
|
|
74
|
+
"typedoc": "0.28.20",
|
|
69
75
|
"typescript": "5.9.3"
|
|
70
76
|
},
|
|
71
77
|
"engines": {
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$ref": "#/definitions/Config",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"ColourGroup": {
|
|
6
|
+
"enum": ["white", "colour", "dark", "sport", "any"],
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"Config": {
|
|
10
|
+
"additionalProperties": false,
|
|
11
|
+
"description": "The washing machine and the chart that describes it, in one place. Both halves are exactly what `parseMachine`/`instructionsFromRows` already produce — this is a wrapper around the pair, not a third shape.",
|
|
12
|
+
"properties": {
|
|
13
|
+
"chart": {
|
|
14
|
+
"items": {
|
|
15
|
+
"$ref": "#/definitions/Instruction"
|
|
16
|
+
},
|
|
17
|
+
"type": "array"
|
|
18
|
+
},
|
|
19
|
+
"machine": {
|
|
20
|
+
"$ref": "#/definitions/Machine"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"required": ["machine", "chart"],
|
|
24
|
+
"type": "object"
|
|
25
|
+
},
|
|
26
|
+
"Instruction": {
|
|
27
|
+
"additionalProperties": false,
|
|
28
|
+
"description": "One CSV row: everything needed to wash, iron and dry one pile of laundry.\n\nThe machine-facing fields are plain strings rather than unions, because what counts as valid depends on the machine file you point this at. `csv.ts` checks each of them against that machine as it parses, so nothing downstream has to wonder whether a programme name exists.",
|
|
29
|
+
"properties": {
|
|
30
|
+
"clothingType": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
},
|
|
33
|
+
"colourGroup": {
|
|
34
|
+
"$ref": "#/definitions/ColourGroup"
|
|
35
|
+
},
|
|
36
|
+
"detergent": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"drying": {
|
|
40
|
+
"type": "string"
|
|
41
|
+
},
|
|
42
|
+
"duration": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"fabricSoftener": {
|
|
46
|
+
"type": "boolean"
|
|
47
|
+
},
|
|
48
|
+
"ironSetting": {
|
|
49
|
+
"description": "Thermostat position. Empty when `ironing` is false.",
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"ironing": {
|
|
53
|
+
"description": "Whether this pile gets ironed at all.",
|
|
54
|
+
"type": "boolean"
|
|
55
|
+
},
|
|
56
|
+
"ironingNotes": {
|
|
57
|
+
"description": "How to iron it, or why you don't. Free prose and often empty, because most of what there is to say about a pile nobody irons is already said by `ironing` being false.",
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"mixTags": {
|
|
61
|
+
"items": {
|
|
62
|
+
"$ref": "#/definitions/MixTag"
|
|
63
|
+
},
|
|
64
|
+
"type": "array"
|
|
65
|
+
},
|
|
66
|
+
"notes": {
|
|
67
|
+
"type": "string"
|
|
68
|
+
},
|
|
69
|
+
"options": {
|
|
70
|
+
"items": {
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"type": "array"
|
|
74
|
+
},
|
|
75
|
+
"program": {
|
|
76
|
+
"type": "string"
|
|
77
|
+
},
|
|
78
|
+
"spin": {
|
|
79
|
+
"type": "string"
|
|
80
|
+
},
|
|
81
|
+
"temperature": {
|
|
82
|
+
"type": "string"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"required": [
|
|
86
|
+
"clothingType",
|
|
87
|
+
"detergent",
|
|
88
|
+
"fabricSoftener",
|
|
89
|
+
"temperature",
|
|
90
|
+
"spin",
|
|
91
|
+
"duration",
|
|
92
|
+
"program",
|
|
93
|
+
"options",
|
|
94
|
+
"ironing",
|
|
95
|
+
"ironingNotes",
|
|
96
|
+
"ironSetting",
|
|
97
|
+
"drying",
|
|
98
|
+
"colourGroup",
|
|
99
|
+
"mixTags",
|
|
100
|
+
"notes"
|
|
101
|
+
],
|
|
102
|
+
"type": "object"
|
|
103
|
+
},
|
|
104
|
+
"Iron": {
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"properties": {
|
|
107
|
+
"name": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
},
|
|
110
|
+
"settings": {
|
|
111
|
+
"description": "Thermostat positions in order, coolest first.",
|
|
112
|
+
"items": {
|
|
113
|
+
"$ref": "#/definitions/IronSetting"
|
|
114
|
+
},
|
|
115
|
+
"type": "array"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"required": ["name", "settings"],
|
|
119
|
+
"type": "object"
|
|
120
|
+
},
|
|
121
|
+
"IronSetting": {
|
|
122
|
+
"additionalProperties": false,
|
|
123
|
+
"properties": {
|
|
124
|
+
"detail": {
|
|
125
|
+
"type": "string"
|
|
126
|
+
},
|
|
127
|
+
"dots": {
|
|
128
|
+
"type": "string"
|
|
129
|
+
},
|
|
130
|
+
"key": {
|
|
131
|
+
"type": "string"
|
|
132
|
+
},
|
|
133
|
+
"label": {
|
|
134
|
+
"type": "string"
|
|
135
|
+
},
|
|
136
|
+
"steam": {
|
|
137
|
+
"type": "boolean"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"required": ["key", "dots", "label", "detail", "steam"],
|
|
141
|
+
"type": "object"
|
|
142
|
+
},
|
|
143
|
+
"Machine": {
|
|
144
|
+
"additionalProperties": false,
|
|
145
|
+
"properties": {
|
|
146
|
+
"iron": {
|
|
147
|
+
"$ref": "#/definitions/Iron"
|
|
148
|
+
},
|
|
149
|
+
"washer": {
|
|
150
|
+
"$ref": "#/definitions/Washer"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"required": ["washer", "iron"],
|
|
154
|
+
"type": "object"
|
|
155
|
+
},
|
|
156
|
+
"MixTag": {
|
|
157
|
+
"enum": ["lint-shedder", "lint-magnet", "dye-bleeder", "solo"],
|
|
158
|
+
"type": "string"
|
|
159
|
+
},
|
|
160
|
+
"Washer": {
|
|
161
|
+
"additionalProperties": false,
|
|
162
|
+
"description": "The appliances a chart is drawn for, as data rather than code.\n\nEverything the PDFs render — dial angles, which chips exist, what a valid CSV value is — comes from a machine file, so pointing this at a different washing machine is editing JSON rather than editing TypeScript. The labels in that file are copied off the fascia in whatever language it is printed in, and nothing here ever translates them: a chart that says \"Cottons\" when the dial says \"Katoen\" is worse than no chart, because you have to translate it back while standing in front of the machine.",
|
|
163
|
+
"properties": {
|
|
164
|
+
"capacity": {
|
|
165
|
+
"type": "string"
|
|
166
|
+
},
|
|
167
|
+
"name": {
|
|
168
|
+
"type": "string"
|
|
169
|
+
},
|
|
170
|
+
"options": {
|
|
171
|
+
"items": {
|
|
172
|
+
"type": "string"
|
|
173
|
+
},
|
|
174
|
+
"type": "array"
|
|
175
|
+
},
|
|
176
|
+
"programs": {
|
|
177
|
+
"description": "Dial labels in physical order from twelve o'clock, clockwise. Index is the angle.",
|
|
178
|
+
"items": {
|
|
179
|
+
"type": "string"
|
|
180
|
+
},
|
|
181
|
+
"type": "array"
|
|
182
|
+
},
|
|
183
|
+
"spins": {
|
|
184
|
+
"items": {
|
|
185
|
+
"type": "string"
|
|
186
|
+
},
|
|
187
|
+
"type": "array"
|
|
188
|
+
},
|
|
189
|
+
"temperatures": {
|
|
190
|
+
"items": {
|
|
191
|
+
"type": "string"
|
|
192
|
+
},
|
|
193
|
+
"type": "array"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"required": ["name", "capacity", "programs", "temperatures", "spins", "options"],
|
|
197
|
+
"type": "object"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mixing-DzbYAriI.mjs","names":[],"sources":["../src/machine.ts","../src/types.ts","../src/rows.ts","../src/config.ts","../src/mixing.ts"],"sourcesContent":["/**\n * The appliances a chart is drawn for, as data rather than code.\n *\n * Everything the PDFs render — dial angles, which chips exist, what a valid CSV\n * value is — comes from a machine file, so pointing this at a different washing\n * machine is editing JSON rather than editing TypeScript. The labels in that\n * file are copied off the fascia in whatever language it is printed in, and\n * nothing here ever translates them: a chart that says \"Cottons\" when the dial\n * says \"Katoen\" is worse than no chart, because you have to translate it back\n * while standing in front of the machine.\n */\n\nexport interface Washer {\n name: string;\n capacity: string;\n /** Dial labels in physical order from twelve o'clock, clockwise. Index is the angle. */\n programs: string[];\n temperatures: string[];\n spins: string[];\n options: string[];\n}\n\nexport interface IronSetting {\n key: string;\n dots: string;\n label: string;\n detail: string;\n steam: boolean;\n}\n\nexport interface Iron {\n name: string;\n /** Thermostat positions in order, coolest first. */\n settings: IronSetting[];\n}\n\nexport interface Machine {\n washer: Washer;\n iron: Iron;\n}\n\nfunction fail(what: string): never {\n throw new Error(`machine: ${what}`);\n}\n\nfunction stringList(value: unknown, field: string, minimum: number): string[] {\n if (!Array.isArray(value) || value.some((entry) => typeof entry !== \"string\" || entry === \"\")) {\n fail(`${field} must be a list of non-empty strings`);\n }\n const list = value as string[];\n if (list.length < minimum)\n fail(`${field} needs at least ${minimum} entries, found ${list.length}`);\n if (new Set(list).size !== list.length) fail(`${field} repeats a value`);\n return list;\n}\n\nfunction text(value: unknown, field: string, fallback?: string): string {\n if (typeof value === \"string\" && value !== \"\") return value;\n if (fallback !== undefined) return fallback;\n return fail(`${field} must be a non-empty string`);\n}\n\nfunction parseIronSetting(value: unknown, index: number): IronSetting {\n if (typeof value !== \"object\" || value === null)\n fail(`iron.settings[${index}] must be an object`);\n const raw = value as Record<string, unknown>;\n const key = text(raw.key, `iron.settings[${index}].key`);\n return {\n key,\n dots: typeof raw.dots === \"string\" ? raw.dots : \"\",\n label: text(raw.label, `iron.settings[${index}].label`),\n detail: text(raw.detail, `iron.settings[${index}].detail`, \"\"),\n steam: raw.steam === true,\n };\n}\n\n/**\n * Checks a parsed machine file and hands back something the renderer can use.\n * Every failure names the field, because the fix is always an edit to that\n * line of JSON.\n */\nexport function parseMachine(value: unknown): Machine {\n if (typeof value !== \"object\" || value === null) fail(\"the file must contain an object\");\n const raw = value as Record<string, unknown>;\n\n if (typeof raw.washer !== \"object\" || raw.washer === null) fail(\"washer is missing\");\n if (typeof raw.iron !== \"object\" || raw.iron === null) fail(\"iron is missing\");\n\n const washerRaw = raw.washer as Record<string, unknown>;\n const ironRaw = raw.iron as Record<string, unknown>;\n\n const settings = Array.isArray(ironRaw.settings)\n ? ironRaw.settings\n : fail(\"iron.settings is missing\");\n if (settings.length < 2) fail(\"iron.settings needs at least 2 positions to draw a ring\");\n\n const keys = settings.map((setting, index) => parseIronSetting(setting, index));\n if (new Set(keys.map((setting) => setting.key)).size !== keys.length) {\n fail(\"iron.settings repeats a key\");\n }\n\n return {\n washer: {\n name: text(washerRaw.name, \"washer.name\"),\n capacity: text(washerRaw.capacity, \"washer.capacity\", \"\"),\n programs: stringList(washerRaw.programs, \"washer.programs\", 2),\n temperatures: stringList(washerRaw.temperatures, \"washer.temperatures\", 1),\n spins: stringList(washerRaw.spins, \"washer.spins\", 1),\n options: stringList(washerRaw.options ?? [], \"washer.options\", 0),\n },\n iron: {\n name: text(ironRaw.name, \"iron.name\"),\n settings: keys,\n },\n };\n}\n\nexport function ironSetting(machine: Machine, key: string): IronSetting | undefined {\n return machine.iron.settings.find((setting) => setting.key === key);\n}\n\n/**\n * The keys a row may write in `iron_setting`, coolest first.\n *\n * There is no key for \"do not iron\". That is the `ironing` column's job, and\n * two places to say the same thing is two places to disagree.\n */\nexport function ironSettingKeys(machine: Machine): string[] {\n return machine.iron.settings.map((setting) => setting.key);\n}\n\n/**\n * `40` becomes `40°`; `cold` stays `cold`. The machine file is free to use\n * whatever word its display shows for the cold wash, so the degree sign is\n * decided by whether the value is a number rather than by a list of exceptions.\n */\nexport function formatTemperature(value: string): string {\n return /^\\d+$/.test(value) ? `${value}°` : value;\n}\n","/** Which pile a garment belongs to on colour grounds. `any` mixes with all. */\nexport const colourGroups = [\"white\", \"colour\", \"dark\", \"sport\", \"any\"] as const;\nexport type ColourGroup = (typeof colourGroups)[number];\n\n/**\n * Reasons two piles might not belong together even when the machine settings\n * agree. See `canMix` in `mixing.ts` for how each one is applied.\n */\nexport const mixTags = [\"lint-shedder\", \"lint-magnet\", \"dye-bleeder\", \"solo\"] as const;\nexport type MixTag = (typeof mixTags)[number];\n\n/**\n * One CSV row: everything needed to wash, iron and dry one pile of laundry.\n *\n * The machine-facing fields are plain strings rather than unions, because what\n * counts as valid depends on the machine file you point this at. `csv.ts`\n * checks each of them against that machine as it parses, so nothing downstream\n * has to wonder whether a programme name exists.\n */\nexport interface Instruction {\n clothingType: string;\n detergent: string;\n fabricSoftener: boolean;\n temperature: string;\n spin: string;\n duration: string;\n program: string;\n options: string[];\n /** Whether this pile gets ironed at all. */\n ironing: boolean;\n /**\n * How to iron it, or why you don't. Free prose and often empty, because most\n * of what there is to say about a pile nobody irons is already said by\n * `ironing` being false.\n */\n ironingNotes: string;\n /** Thermostat position. Empty when `ironing` is false. */\n ironSetting: string;\n drying: string;\n colourGroup: ColourGroup;\n mixTags: MixTag[];\n notes: string;\n}\n\n/** An instruction plus the other piles it may share a drum with. */\nexport interface ResolvedInstruction extends Instruction {\n mixesWith: string[];\n}\n\n/**\n * How long a card or a load is going to tie the machine up.\n *\n * Usually one figure. Piles sharing a load agree on every setting, so they\n * ought to agree on this too — but the chart is data somebody types, and\n * printing both is more honest than picking the first one and hoping.\n */\nexport function durationsOf(group: Instruction[]): string {\n return [...new Set(group.map((item) => item.duration).filter((value) => value !== \"\"))].join(\n \" / \",\n );\n}\n\n/**\n * Which sheet to draw.\n *\n * `full` is the whole chart. The other two are the same chart cut where the\n * work is: washing happens in front of the machine on a Sunday morning, ironing\n * happens at a board on a Wednesday evening, and neither job wants to read past\n * the other's advice to find its own.\n */\nexport const variants = [\"full\", \"wash\", \"iron\"] as const;\nexport type Variant = (typeof variants)[number];\n","import { ironSettingKeys, type Machine } from \"./machine\";\nimport type { ColourGroup, Instruction, MixTag } from \"./types\";\nimport { colourGroups, mixTags } from \"./types\";\n\nexport const COLUMNS = [\n \"clothing_type\",\n \"detergent\",\n \"fabric_softener\",\n \"temperature\",\n \"spin\",\n \"duration\",\n \"program\",\n \"options\",\n \"ironing\",\n \"ironing_notes\",\n \"iron_setting\",\n \"drying\",\n \"colour_group\",\n \"mix_tags\",\n \"notes\",\n] as const;\n\n/** One row, keyed the same way as a CSV column and the chart's JSON Schema. */\nexport type Row = Record<(typeof COLUMNS)[number], string>;\n\nexport class RowError extends Error {\n constructor(row: number, column: string, message: string) {\n super(`row ${row}, column \"${column}\": ${message}`);\n this.name = \"RowError\";\n }\n}\n\n/** `a|b|c` -> `[\"a\", \"b\", \"c\"]`, tolerating stray whitespace and empties. */\nfunction splitList(value: string): string[] {\n return value\n .split(\"|\")\n .map((part) => part.trim())\n .filter((part) => part.length > 0);\n}\n\nfunction oneOf<T extends string>(\n row: number,\n column: string,\n value: string,\n allowed: readonly T[],\n): T {\n if (!(allowed as readonly string[]).includes(value)) {\n throw new RowError(row, column, `\"${value}\" is not one of ${allowed.join(\", \")}`);\n }\n return value as T;\n}\n\nfunction boolean(row: number, column: string, value: string): boolean {\n const normalised = value.trim().toLowerCase();\n if ([\"yes\", \"y\", \"true\", \"1\"].includes(normalised)) return true;\n if ([\"no\", \"n\", \"false\", \"0\"].includes(normalised)) return false;\n throw new RowError(row, column, `\"${value}\" is not a yes/no value`);\n}\n\n/**\n * Checks rows shaped like the chart's schema — the same shape a CSV parses\n * into, or a JSON file round-tripped through `rowsFromInstructions` — against\n * what the appliances in the machine file can actually be set to. A typo in a\n * programme name fails here rather than producing a PDF that tells you to turn\n * the dial to a position that does not exist — and so does a chart written for\n * a different machine than the one you passed.\n */\nexport function instructionsFromRows(\n rows: Record<string, string>[],\n machine: Machine,\n): Instruction[] {\n const { washer } = machine;\n\n if (rows.length === 0) throw new Error(\"the chart has no rows\");\n\n const header = Object.keys(rows[0] as Record<string, string>);\n const missing = COLUMNS.filter((column) => !header.includes(column));\n if (missing.length > 0) {\n throw new Error(`the chart is missing column(s): ${missing.join(\", \")}`);\n }\n\n return rows.map((record, index) => {\n // +2: one for the header row, one because humans count from 1. Kept even\n // for a JSON source, so an error message reads the same regardless of\n // which format the chart came from.\n const row = index + 2;\n\n const clothingType = (record.clothing_type ?? \"\").trim();\n if (clothingType === \"\") throw new RowError(row, \"clothing_type\", \"must not be empty\");\n\n const options = splitList(record.options ?? \"\").map((option) =>\n oneOf(row, \"options\", option, washer.options),\n );\n\n const tags = splitList(record.mix_tags ?? \"\").map((tag) =>\n oneOf<MixTag>(row, \"mix_tags\", tag, mixTags),\n );\n\n // `ironing` decides whether there is a thermostat position at all, so the\n // two are checked together: a pile you never iron has nowhere to point the\n // dial, and a pile you do iron has to say where.\n const ironing = boolean(row, \"ironing\", record.ironing ?? \"\");\n const rawSetting = (record.iron_setting ?? \"\").trim();\n if (!ironing && rawSetting !== \"\") {\n throw new RowError(\n row,\n \"iron_setting\",\n `must be empty when ironing is no, found \"${rawSetting}\"`,\n );\n }\n const ironSetting = ironing\n ? oneOf(row, \"iron_setting\", rawSetting, ironSettingKeys(machine))\n : \"\";\n\n return {\n clothingType,\n detergent: record.detergent ?? \"\",\n fabricSoftener: boolean(row, \"fabric_softener\", record.fabric_softener ?? \"\"),\n temperature: oneOf(row, \"temperature\", record.temperature ?? \"\", washer.temperatures),\n spin: oneOf(row, \"spin\", record.spin ?? \"\", washer.spins),\n duration: record.duration ?? \"\",\n program: oneOf(row, \"program\", record.program ?? \"\", washer.programs),\n options,\n ironing,\n ironingNotes: record.ironing_notes ?? \"\",\n ironSetting,\n drying: record.drying ?? \"\",\n colourGroup: oneOf<ColourGroup>(row, \"colour_group\", record.colour_group ?? \"\", colourGroups),\n mixTags: tags,\n notes: record.notes ?? \"\",\n };\n });\n}\n\n/** The reverse of `instructionsFromRows` — what a JSON export writes out. */\nexport function rowsFromInstructions(instructions: Instruction[]): Row[] {\n return instructions.map((instruction) => ({\n clothing_type: instruction.clothingType,\n detergent: instruction.detergent,\n fabric_softener: instruction.fabricSoftener ? \"yes\" : \"no\",\n temperature: instruction.temperature,\n spin: instruction.spin,\n duration: instruction.duration,\n program: instruction.program,\n options: instruction.options.join(\"|\"),\n ironing: instruction.ironing ? \"yes\" : \"no\",\n ironing_notes: instruction.ironingNotes,\n iron_setting: instruction.ironSetting,\n drying: instruction.drying,\n colour_group: instruction.colourGroup,\n mix_tags: instruction.mixTags.join(\"|\"),\n notes: instruction.notes,\n }));\n}\n\n/**\n * The JSON interchange format for a chart — the same row shape\n * a chart's JSON Schema describes, so a file written here validates against\n * it exactly as a CSV does.\n */\nexport function chartToJson(instructions: Instruction[]): string {\n return `${JSON.stringify(rowsFromInstructions(instructions), null, 2)}\\n`;\n}\n\n/** The other half of `chartToJson`. Throws the same errors `parseInstructions` does. */\nexport function chartFromJson(source: string, machine: Machine): Instruction[] {\n let rows: unknown;\n try {\n rows = JSON.parse(source);\n } catch (error) {\n throw new Error(`not valid JSON: ${error instanceof Error ? error.message : error}`);\n }\n if (!Array.isArray(rows)) throw new Error(\"the chart must be a JSON array of rows\");\n return instructionsFromRows(rows as Record<string, string>[], machine);\n}\n","import { type Machine, parseMachine } from \"./machine\";\nimport { instructionsFromRows, rowsFromInstructions } from \"./rows\";\nimport type { Instruction } from \"./types\";\n\n/**\n * The washing machine and the chart that describes it, in one place. Both\n * halves are exactly what `parseMachine`/`instructionsFromRows` already\n * produce — this is a wrapper around the pair, not a third shape.\n */\nexport interface Config {\n machine: Machine;\n chart: Instruction[];\n}\n\n/**\n * Validates a `{ machine, chart }` object, checking the chart against the\n * machine it's embedded with — never a different one. Every failure names\n * which half is wrong, same as `parseMachine` and `instructionsFromRows` do\n * on their own.\n */\nexport function parseConfig(value: unknown): Config {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"config: the file must contain an object\");\n }\n const raw = value as Record<string, unknown>;\n\n if (!(\"machine\" in raw)) throw new Error(\"config: machine is missing\");\n if (!(\"chart\" in raw)) throw new Error(\"config: chart is missing\");\n\n const machine = parseMachine(raw.machine);\n\n if (!Array.isArray(raw.chart)) throw new Error(\"config: chart must be an array of rows\");\n const chart = instructionsFromRows(raw.chart as Record<string, string>[], machine);\n\n return { machine, chart };\n}\n\n/** The reverse of `parseConfig` — what a JSON export writes out. */\nexport function configToJson(config: Config): string {\n const rows = { machine: config.machine, chart: rowsFromInstructions(config.chart) };\n return `${JSON.stringify(rows, null, 2)}\\n`;\n}\n\n/** The other half of `configToJson`. Throws the same errors `parseConfig` does. */\nexport function configFromJson(source: string): Config {\n let value: unknown;\n try {\n value = JSON.parse(source);\n } catch (error) {\n throw new Error(`config: not valid JSON: ${error instanceof Error ? error.message : error}`);\n }\n return parseConfig(value);\n}\n","import type { Instruction, ResolvedInstruction } from \"./types\";\n\n/** Why two piles cannot share a drum. `null` means they can. */\nexport type Blocker = \"solo\" | \"settings\" | \"colour\" | \"lint\";\n\nexport const blockerLegend: Record<Blocker, string> = {\n solo: \"Wash on its own\",\n settings: \"Different programme, temperature, spin or options\",\n colour: \"Colours would run into each other\",\n lint: \"One sheds lint onto the other\",\n};\n\n/** Short codes used in the compatibility matrix, so a cell stays one glyph. */\nexport const blockerCode: Record<Blocker, string> = {\n solo: \"S\",\n settings: \"P\",\n colour: \"C\",\n lint: \"L\",\n};\n\nfunction sameSettings(a: Instruction, b: Instruction): boolean {\n return (\n a.program === b.program &&\n a.temperature === b.temperature &&\n a.spin === b.spin &&\n a.options.length === b.options.length &&\n a.options.every((option) => b.options.includes(option))\n );\n}\n\nfunction compatibleColours(a: Instruction, b: Instruction): boolean {\n if (a.colourGroup === \"any\" || b.colourGroup === \"any\") return true;\n return a.colourGroup === b.colourGroup;\n}\n\n/**\n * Decides whether two piles can go in the drum together, and if not, why.\n *\n * The order matters: the reason reported is the one you would want to hear\n * first. \"Wash it alone\" beats \"the spin speed differs\", because changing the\n * spin speed would not help.\n */\nexport function mixBlocker(a: Instruction, b: Instruction): Blocker | null {\n if (a.mixTags.includes(\"solo\") || b.mixTags.includes(\"solo\")) return \"solo\";\n\n // Terry sheds lint over everything, so towels only ever go with towels.\n const shedders = [a, b].filter((item) => item.mixTags.includes(\"lint-shedder\"));\n if (shedders.length === 1) return \"lint\";\n\n if (!compatibleColours(a, b)) return \"colour\";\n if (!sameSettings(a, b)) return \"settings\";\n return null;\n}\n\nexport function canMix(a: Instruction, b: Instruction): boolean {\n return mixBlocker(a, b) === null;\n}\n\n/** Annotates each instruction with the other piles it may share a load with. */\nexport function resolve(instructions: Instruction[]): ResolvedInstruction[] {\n return instructions.map((instruction) => ({\n ...instruction,\n mixesWith: instructions\n .filter((other) => other !== instruction && canMix(instruction, other))\n .map((other) => other.clothingType),\n }));\n}\n\n/**\n * Groups piles that can all be washed together — every member compatible with\n * every other, not merely with the first one it met.\n */\nexport function loadGroups<T extends Instruction>(instructions: T[]): T[][] {\n const groups: T[][] = [];\n for (const instruction of instructions) {\n const home = groups.find((group) => group.every((member) => canMix(member, instruction)));\n if (home) home.push(instruction);\n else groups.push([instruction]);\n }\n return groups;\n}\n\nfunction groupBy<T>(items: T[], key: (item: T) => string): T[][] {\n const groups = new Map<string, T[]>();\n for (const item of items) {\n const existing = groups.get(key(item));\n if (existing) existing.push(item);\n else groups.set(key(item), [item]);\n }\n return [...groups.values()];\n}\n\n/**\n * Everything you physically set on the washing machine: the programme, what\n * the display reads, which buttons are lit, and whether softener goes in.\n *\n * Deliberately *not* the prose. Two piles can want the same five settings and\n * still want different detergent or a different drying rack, and those the card\n * lists per pile rather than splitting into two near-identical cards.\n */\nfunction washFingerprint(item: Instruction): string {\n return JSON.stringify([\n item.program,\n item.temperature,\n item.spin,\n [...item.options].sort(),\n item.fabricSoftener,\n ]);\n}\n\n/**\n * Piles you set the machine and the iron up for identically. Every dial\n * drawing on their cards would be the same drawing, so they get one card\n * listing all the names.\n */\nexport function cardGroups<T extends Instruction>(instructions: T[]): T[][] {\n return groupBy(instructions, (item) =>\n JSON.stringify([washFingerprint(item), item.ironing, item.ironSetting]),\n );\n}\n\n/**\n * The same, for a sheet with no iron on it. Dark, Black Socks and Denim each\n * need their own card on the full chart only because they want three different\n * thermostat positions; standing at the machine they are one wash.\n */\nexport function washGroups<T extends Instruction>(instructions: T[]): T[][] {\n return groupBy(instructions, washFingerprint);\n}\n\n/**\n * Piles by where the iron's thermostat points, coolest first.\n *\n * An ironing sheet is read the other way round from a washing one. You do not\n * fetch a pile and look up its setting — you set the iron once and work through\n * everything that goes at that heat, so the thermostat position is the heading\n * and the piles are the list under it. `order` is `ironSettingKeys`; a pile you\n * never iron has no position in it and sorts last, which is right — it is the\n * pile you never pick up.\n */\nexport function ironGroups<T extends Instruction>(\n instructions: T[],\n order: readonly string[],\n): T[][] {\n const rank = (setting: string) => {\n const at = order.indexOf(setting);\n return at < 0 ? order.length : at;\n };\n return groupBy(instructions, (item) => item.ironSetting).sort(\n (a, b) => rank((a[0] as T).ironSetting) - rank((b[0] as T).ironSetting),\n );\n}\n"],"mappings":";AAyCA,SAAS,KAAK,MAAqB;CACjC,MAAM,IAAI,MAAM,YAAY,MAAM;AACpC;AAEA,SAAS,WAAW,OAAgB,OAAe,SAA2B;CAC5E,IAAI,CA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