@washy-washy/core 1.4.0 → 1.5.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/dist/browser.d.mts +2 -2
- package/dist/browser.mjs +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{mixing-BPsUUVhp.mjs → mixing-DEthnE5k.mjs} +17 -6
- package/dist/mixing-DEthnE5k.mjs.map +1 -0
- package/dist/{rows-DJZMldFv.d.mts → rows-DuLRhKiW.d.mts} +16 -5
- package/package.json +1 -1
- package/schema/config.schema.json +3 -3
- package/dist/mixing-BPsUUVhp.mjs.map +0 -1
package/dist/browser.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as mixTags, C as ColourGroup, D as Variant, E as ResolvedInstruction, F as
|
|
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 };
|
|
1
|
+
import { A as mixTags, B as formatTemperature, C as ColourGroup, D as Variant, E as ResolvedInstruction, F as MAX_WASHER_PROGRAM_LENGTH, H as ironSettingKeys, I as MAX_WASHER_SPIN_LENGTH, L as MAX_WASHER_TEMPERATURE_LENGTH, M as Iron, N as IronSetting, O as colourGroups, P as MAX_WASHER_OPTION_LENGTH, R as Machine, S as parseConfig, T as MixTag, U as parseMachine, V as ironSetting, _ 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 Washer } from "./rows-DuLRhKiW.mjs";
|
|
2
|
+
export { Blocker, COLUMNS, CONFIG_SCHEMA_URL, ColourGroup, Config, Instruction, Iron, IronSetting, MAX_WASHER_OPTION_LENGTH, MAX_WASHER_PROGRAM_LENGTH, MAX_WASHER_SPIN_LENGTH, MAX_WASHER_TEMPERATURE_LENGTH, 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 variants, D as
|
|
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 };
|
|
1
|
+
import { A as ironSettingKeys, C as variants, D as MAX_WASHER_TEMPERATURE_LENGTH, E as MAX_WASHER_SPIN_LENGTH, O as formatTemperature, S as mixTags, T as MAX_WASHER_PROGRAM_LENGTH, _ 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, j as parseMachine, k as ironSetting, 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 MAX_WASHER_OPTION_LENGTH, x as durationsOf, y as rowsFromInstructions } from "./mixing-DEthnE5k.mjs";
|
|
2
|
+
export { COLUMNS, CONFIG_SCHEMA_URL, MAX_WASHER_OPTION_LENGTH, MAX_WASHER_PROGRAM_LENGTH, MAX_WASHER_SPIN_LENGTH, MAX_WASHER_TEMPERATURE_LENGTH, 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,4 +1,4 @@
|
|
|
1
|
-
import { A as mixTags, C as ColourGroup, D as Variant, E as ResolvedInstruction, F as
|
|
1
|
+
import { A as mixTags, B as formatTemperature, C as ColourGroup, D as Variant, E as ResolvedInstruction, F as MAX_WASHER_PROGRAM_LENGTH, H as ironSettingKeys, I as MAX_WASHER_SPIN_LENGTH, L as MAX_WASHER_TEMPERATURE_LENGTH, M as Iron, N as IronSetting, O as colourGroups, P as MAX_WASHER_OPTION_LENGTH, R as Machine, S as parseConfig, T as MixTag, U as parseMachine, V as ironSetting, _ 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 Washer } from "./rows-DuLRhKiW.mjs";
|
|
2
2
|
//#region src/csv.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Parses the instruction CSV. See `instructionsFromRows` for the row rules.
|
|
@@ -10,5 +10,5 @@ import { A as mixTags, C as ColourGroup, D as Variant, E as ResolvedInstruction,
|
|
|
10
10
|
*/
|
|
11
11
|
declare function parseInstructions(source: string, machine: Machine): Instruction[];
|
|
12
12
|
//#endregion
|
|
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 };
|
|
13
|
+
export { Blocker, COLUMNS, CONFIG_SCHEMA_URL, ColourGroup, Config, Instruction, Iron, IronSetting, MAX_WASHER_OPTION_LENGTH, MAX_WASHER_PROGRAM_LENGTH, MAX_WASHER_SPIN_LENGTH, MAX_WASHER_TEMPERATURE_LENGTH, 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 };
|
|
14
14
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as variants, D as
|
|
1
|
+
import { A as ironSettingKeys, C as variants, D as MAX_WASHER_TEMPERATURE_LENGTH, E as MAX_WASHER_SPIN_LENGTH, O as formatTemperature, S as mixTags, T as MAX_WASHER_PROGRAM_LENGTH, _ 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, j as parseMachine, k as ironSetting, 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 MAX_WASHER_OPTION_LENGTH, x as durationsOf, y as rowsFromInstructions } from "./mixing-DEthnE5k.mjs";
|
|
2
2
|
import { parse } from "csv-parse/sync";
|
|
3
3
|
//#region src/csv.ts
|
|
4
4
|
/**
|
|
@@ -20,6 +20,6 @@ function parseInstructions(source, machine) {
|
|
|
20
20
|
return instructionsFromRows(records, machine);
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
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 };
|
|
23
|
+
export { COLUMNS, CONFIG_SCHEMA_URL, MAX_WASHER_OPTION_LENGTH, MAX_WASHER_PROGRAM_LENGTH, MAX_WASHER_SPIN_LENGTH, MAX_WASHER_TEMPERATURE_LENGTH, 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 };
|
|
24
24
|
|
|
25
25
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -18,6 +18,17 @@ function text(value, field, maxLength, fallback) {
|
|
|
18
18
|
}
|
|
19
19
|
/** How many dots a thermostat position's dial label draws — never more than a handful. */
|
|
20
20
|
const MAX_DOTS_LENGTH = 5;
|
|
21
|
+
/** Longest a single washer.programs dial caption can be. */
|
|
22
|
+
const MAX_WASHER_PROGRAM_LENGTH = 32;
|
|
23
|
+
/**
|
|
24
|
+
* Longest a single washer.temperatures entry can be — the reference sheet's
|
|
25
|
+
* °C column. Raised from 12 once washy-washy-pdf#61 made room (see #36).
|
|
26
|
+
*/
|
|
27
|
+
const MAX_WASHER_TEMPERATURE_LENGTH = 15;
|
|
28
|
+
/** Longest a single washer.spins entry can be. */
|
|
29
|
+
const MAX_WASHER_SPIN_LENGTH = 10;
|
|
30
|
+
/** Longest a single washer.options chip can be. */
|
|
31
|
+
const MAX_WASHER_OPTION_LENGTH = 20;
|
|
21
32
|
function parseIronSetting(value, index) {
|
|
22
33
|
if (typeof value !== "object" || value === null) fail(`iron.settings[${index}] must be an object`);
|
|
23
34
|
const raw = value;
|
|
@@ -57,9 +68,9 @@ function parseMachine(value) {
|
|
|
57
68
|
return {
|
|
58
69
|
washer: {
|
|
59
70
|
name: text(washerRaw.name, "washer.name", 60),
|
|
60
|
-
capacity: text(washerRaw.capacity, "washer.capacity",
|
|
71
|
+
capacity: text(washerRaw.capacity, "washer.capacity", 30, ""),
|
|
61
72
|
programs: stringList(washerRaw.programs, "washer.programs", 2, 32),
|
|
62
|
-
temperatures: stringList(washerRaw.temperatures, "washer.temperatures", 1,
|
|
73
|
+
temperatures: stringList(washerRaw.temperatures, "washer.temperatures", 1, 15),
|
|
63
74
|
spins: stringList(washerRaw.spins, "washer.spins", 1, 10),
|
|
64
75
|
options: stringList(washerRaw.options ?? [], "washer.options", 0, 20)
|
|
65
76
|
},
|
|
@@ -265,10 +276,10 @@ function instructionsFromRows(rows, machine) {
|
|
|
265
276
|
ironing,
|
|
266
277
|
ironingNotes: maxLength(row, "ironing_notes", record.ironing_notes ?? "", 400),
|
|
267
278
|
ironSetting,
|
|
268
|
-
drying: maxLength(row, "drying", record.drying ?? "",
|
|
279
|
+
drying: maxLength(row, "drying", record.drying ?? "", 230),
|
|
269
280
|
colourGroup: oneOf(row, "colour_group", record.colour_group ?? "", colourGroups),
|
|
270
281
|
mixTags: tags,
|
|
271
|
-
notes: maxLength(row, "notes", record.notes ?? "",
|
|
282
|
+
notes: maxLength(row, "notes", record.notes ?? "", 570),
|
|
272
283
|
referenceName: maxLength(row, "reference_name", record.reference_name ?? "", 80),
|
|
273
284
|
referenceLink: maxLength(row, "reference_link", record.reference_link ?? "", 2048)
|
|
274
285
|
};
|
|
@@ -569,6 +580,6 @@ function ironGroups(instructions, order) {
|
|
|
569
580
|
return groupBy(instructions, (item) => item.ironSetting).sort((a, b) => rank(a[0].ironSetting) - rank(b[0].ironSetting));
|
|
570
581
|
}
|
|
571
582
|
//#endregion
|
|
572
|
-
export { variants as C,
|
|
583
|
+
export { ironSettingKeys as A, variants as C, MAX_WASHER_TEMPERATURE_LENGTH as D, MAX_WASHER_SPIN_LENGTH as E, formatTemperature as O, mixTags as S, MAX_WASHER_PROGRAM_LENGTH 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, parseMachine as j, ironSetting as k, 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, MAX_WASHER_OPTION_LENGTH as w, durationsOf as x, rowsFromInstructions as y };
|
|
573
584
|
|
|
574
|
-
//# sourceMappingURL=mixing-
|
|
585
|
+
//# sourceMappingURL=mixing-DEthnE5k.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixing-DEthnE5k.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 /** @maxLength 60 */\n name: string;\n /** @maxLength 30 */\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 /** @maxLength 30 */\n key: string;\n /** @maxLength 5 */\n dots: string;\n /** @maxLength 20 */\n label: string;\n /** @maxLength 60 */\n detail: string;\n steam: boolean;\n}\n\nexport interface Iron {\n /** @maxLength 60 */\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, maxLength: 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 const overlong = list.find((entry) => entry.length > maxLength);\n if (overlong !== undefined) {\n fail(`${field} entries must be at most ${maxLength} characters, found \"${overlong}\"`);\n }\n return list;\n}\n\nfunction text(value: unknown, field: string, maxLength: number, fallback?: string): string {\n const resolved =\n typeof value === \"string\" && value !== \"\"\n ? value\n : fallback !== undefined\n ? fallback\n : fail(`${field} must be a non-empty string`);\n if (resolved.length > maxLength) {\n fail(`${field} must be at most ${maxLength} characters, found ${resolved.length}`);\n }\n return resolved;\n}\n\n/** How many dots a thermostat position's dial label draws — never more than a handful. */\nconst MAX_DOTS_LENGTH = 5;\n\n// Per-entry caps for the washer's four dial lists, from @washy-washy/pdf's\n// actual fixed-width slots (dial captions, the reference sheet's columns) —\n// long enough for anything a real fascia prints, short enough that a card or\n// sheet never has to guess how to fit one. Consumers wiring up client-side\n// validation (a form's maxLength, say) should import these rather than\n// hardcoding the numbers a second time.\n\n/** Longest a single washer.programs dial caption can be. */\nexport const MAX_WASHER_PROGRAM_LENGTH = 32;\n\n/**\n * Longest a single washer.temperatures entry can be — the reference sheet's\n * °C column. Raised from 12 once washy-washy-pdf#61 made room (see #36).\n */\nexport const MAX_WASHER_TEMPERATURE_LENGTH = 15;\n\n/** Longest a single washer.spins entry can be. */\nexport const MAX_WASHER_SPIN_LENGTH = 10;\n\n/** Longest a single washer.options chip can be. */\nexport const MAX_WASHER_OPTION_LENGTH = 20;\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`, 30);\n const dots = typeof raw.dots === \"string\" ? raw.dots : \"\";\n if (dots.length > MAX_DOTS_LENGTH) {\n fail(`iron.settings[${index}].dots must be at most ${MAX_DOTS_LENGTH} characters`);\n }\n return {\n key,\n dots,\n label: text(raw.label, `iron.settings[${index}].label`, 20),\n detail: text(raw.detail, `iron.settings[${index}].detail`, 60, \"\"),\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\", 60),\n capacity: text(washerRaw.capacity, \"washer.capacity\", 30, \"\"),\n programs: stringList(washerRaw.programs, \"washer.programs\", 2, MAX_WASHER_PROGRAM_LENGTH),\n temperatures: stringList(\n washerRaw.temperatures,\n \"washer.temperatures\",\n 1,\n MAX_WASHER_TEMPERATURE_LENGTH,\n ),\n spins: stringList(washerRaw.spins, \"washer.spins\", 1, MAX_WASHER_SPIN_LENGTH),\n options: stringList(washerRaw.options ?? [], \"washer.options\", 0, MAX_WASHER_OPTION_LENGTH),\n },\n iron: {\n name: text(ironRaw.name, \"iron.name\", 60),\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 /** @maxLength 60 */\n clothingType: string;\n /** @maxLength 200 */\n detergent: string;\n fabricSoftener: boolean;\n temperature: string;\n spin: string;\n /** @maxLength 12 */\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 * @maxLength 400\n */\n ironingNotes: string;\n /** Thermostat position. Empty when `ironing` is false. */\n ironSetting: string;\n /** @maxLength 230 */\n drying: string;\n colourGroup: ColourGroup;\n mixTags: MixTag[];\n /** @maxLength 570 */\n notes: string;\n /**\n * Who to credit for a care instruction that isn't obvious from the garment\n * itself — \"the label says 40°\" doesn't need one, \"the manufacturer says\n * wash these alone\" might. Empty when there's nothing to cite.\n * @maxLength 80\n */\n referenceName: string;\n /**\n * A link backing up `referenceName`. Empty when there's nothing to cite.\n * @maxLength 2048\n */\n referenceLink: 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 \"reference_name\",\n \"reference_link\",\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\n/**\n * Caps free-text fields the PDFs render, so a value long enough to visibly\n * crowd a card or reference-sheet row is rejected here rather than in a\n * layout that only degrades quietly. Limits from @washy-washy/pdf's actual\n * fixed-width slots and wrap-safety analysis, not a guess.\n */\nfunction maxLength(row: number, column: string, value: string, max: number): string {\n if (value.length > max) {\n throw new RowError(row, column, `must be at most ${max} characters, found ${value.length}`);\n }\n return value;\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\nconst DURATION_PATTERN = /^~?\\d+:[0-5]\\d$/;\n\n/** Empty stays empty — some piles genuinely have no duration on record. */\nfunction duration(row: number, column: string, value: string): string {\n if (value === \"\") return value;\n if (!DURATION_PATTERN.test(value)) {\n throw new RowError(row, column, `must match H:MM, found \"${value}\"`);\n }\n return maxLength(row, column, value, 12);\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 = maxLength(row, \"clothing_type\", (record.clothing_type ?? \"\").trim(), 60);\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: maxLength(row, \"detergent\", record.detergent ?? \"\", 200),\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: duration(row, \"duration\", record.duration ?? \"\"),\n program: oneOf(row, \"program\", record.program ?? \"\", washer.programs),\n options,\n ironing,\n ironingNotes: maxLength(row, \"ironing_notes\", record.ironing_notes ?? \"\", 400),\n ironSetting,\n drying: maxLength(row, \"drying\", record.drying ?? \"\", 230),\n colourGroup: oneOf<ColourGroup>(row, \"colour_group\", record.colour_group ?? \"\", colourGroups),\n mixTags: tags,\n notes: maxLength(row, \"notes\", record.notes ?? \"\", 570),\n referenceName: maxLength(row, \"reference_name\", record.reference_name ?? \"\", 80),\n referenceLink: maxLength(row, \"reference_link\", record.reference_link ?? \"\", 2048),\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 reference_name: instruction.referenceName,\n reference_link: instruction.referenceLink,\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":";AAgDA,SAAS,KAAK,MAAqB;CACjC,MAAM,IAAI,MAAM,YAAY,MAAM;AACpC;AAEA,SAAS,WAAW,OAAgB,OAAe,SAAiB,WAA6B;CAC/F,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,MAAM,WAAW,KAAK,MAAM,UAAU,MAAM,SAAS,SAAS;CAC9D,IAAI,aAAa,KAAA,GACf,KAAK,GAAG,MAAM,2BAA2B,UAAU,sBAAsB,SAAS,EAAE;CAEtF,OAAO;AACT;AAEA,SAAS,KAAK,OAAgB,OAAe,WAAmB,UAA2B;CACzF,MAAM,WACJ,OAAO,UAAU,YAAY,UAAU,KACnC,QACA,aAAa,KAAA,IACX,WACA,KAAK,GAAG,MAAM,4BAA4B;CAClD,IAAI,SAAS,SAAS,WACpB,KAAK,GAAG,MAAM,mBAAmB,UAA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AS,QAAW,OAAY,KAAiC;CAC/D,MAAM,yBAAS,IAAI,IAAiB;CACpC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,OAAO,IAAI,IAAI,IAAI,CAAC;EACrC,IAAI,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"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
interface Washer {
|
|
14
14
|
/** @maxLength 60 */
|
|
15
15
|
name: string;
|
|
16
|
-
/** @maxLength
|
|
16
|
+
/** @maxLength 30 */
|
|
17
17
|
capacity: string;
|
|
18
18
|
/** Dial labels in physical order from twelve o'clock, clockwise. Index is the angle. */
|
|
19
19
|
programs: string[];
|
|
@@ -42,6 +42,17 @@ interface Machine {
|
|
|
42
42
|
washer: Washer;
|
|
43
43
|
iron: Iron;
|
|
44
44
|
}
|
|
45
|
+
/** Longest a single washer.programs dial caption can be. */
|
|
46
|
+
declare const MAX_WASHER_PROGRAM_LENGTH = 32;
|
|
47
|
+
/**
|
|
48
|
+
* Longest a single washer.temperatures entry can be — the reference sheet's
|
|
49
|
+
* °C column. Raised from 12 once washy-washy-pdf#61 made room (see #36).
|
|
50
|
+
*/
|
|
51
|
+
declare const MAX_WASHER_TEMPERATURE_LENGTH = 15;
|
|
52
|
+
/** Longest a single washer.spins entry can be. */
|
|
53
|
+
declare const MAX_WASHER_SPIN_LENGTH = 10;
|
|
54
|
+
/** Longest a single washer.options chip can be. */
|
|
55
|
+
declare const MAX_WASHER_OPTION_LENGTH = 20;
|
|
45
56
|
/**
|
|
46
57
|
* Checks a parsed machine file and hands back something the renderer can use.
|
|
47
58
|
* Every failure names the field, because the fix is always an edit to that
|
|
@@ -128,11 +139,11 @@ interface Instruction {
|
|
|
128
139
|
ironingNotes: string;
|
|
129
140
|
/** Thermostat position. Empty when `ironing` is false. */
|
|
130
141
|
ironSetting: string;
|
|
131
|
-
/** @maxLength
|
|
142
|
+
/** @maxLength 230 */
|
|
132
143
|
drying: string;
|
|
133
144
|
colourGroup: ColourGroup;
|
|
134
145
|
mixTags: MixTag[];
|
|
135
|
-
/** @maxLength
|
|
146
|
+
/** @maxLength 570 */
|
|
136
147
|
notes: string;
|
|
137
148
|
/**
|
|
138
149
|
* Who to credit for a care instruction that isn't obvious from the garment
|
|
@@ -368,5 +379,5 @@ declare function chartToJson(instructions: Instruction[]): string;
|
|
|
368
379
|
*/
|
|
369
380
|
declare function chartFromJson(source: string, machine: Machine): Instruction[];
|
|
370
381
|
//#endregion
|
|
371
|
-
export { mixTags as A, ColourGroup as C, Variant as D, ResolvedInstruction as E,
|
|
372
|
-
//# sourceMappingURL=rows-
|
|
382
|
+
export { mixTags as A, formatTemperature as B, ColourGroup as C, Variant as D, ResolvedInstruction as E, MAX_WASHER_PROGRAM_LENGTH as F, ironSettingKeys as H, MAX_WASHER_SPIN_LENGTH as I, MAX_WASHER_TEMPERATURE_LENGTH as L, Iron as M, IronSetting as N, colourGroups as O, MAX_WASHER_OPTION_LENGTH as P, Machine as R, parseConfig as S, MixTag as T, parseMachine as U, ironSetting as V, 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, Washer as z };
|
|
383
|
+
//# sourceMappingURL=rows-DuLRhKiW.d.mts.map
|
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"type": "string"
|
|
40
40
|
},
|
|
41
41
|
"drying": {
|
|
42
|
-
"maxLength":
|
|
42
|
+
"maxLength": 230,
|
|
43
43
|
"type": "string"
|
|
44
44
|
},
|
|
45
45
|
"duration": {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"type": "array"
|
|
70
70
|
},
|
|
71
71
|
"notes": {
|
|
72
|
-
"maxLength":
|
|
72
|
+
"maxLength": 570,
|
|
73
73
|
"type": "string"
|
|
74
74
|
},
|
|
75
75
|
"options": {
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"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.",
|
|
186
186
|
"properties": {
|
|
187
187
|
"capacity": {
|
|
188
|
-
"maxLength":
|
|
188
|
+
"maxLength": 30,
|
|
189
189
|
"type": "string"
|
|
190
190
|
},
|
|
191
191
|
"name": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mixing-BPsUUVhp.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 /** @maxLength 60 */\n name: string;\n /** @maxLength 20 */\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 /** @maxLength 30 */\n key: string;\n /** @maxLength 5 */\n dots: string;\n /** @maxLength 20 */\n label: string;\n /** @maxLength 60 */\n detail: string;\n steam: boolean;\n}\n\nexport interface Iron {\n /** @maxLength 60 */\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, maxLength: 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 const overlong = list.find((entry) => entry.length > maxLength);\n if (overlong !== undefined) {\n fail(`${field} entries must be at most ${maxLength} characters, found \"${overlong}\"`);\n }\n return list;\n}\n\nfunction text(value: unknown, field: string, maxLength: number, fallback?: string): string {\n const resolved =\n typeof value === \"string\" && value !== \"\"\n ? value\n : fallback !== undefined\n ? fallback\n : fail(`${field} must be a non-empty string`);\n if (resolved.length > maxLength) {\n fail(`${field} must be at most ${maxLength} characters, found ${resolved.length}`);\n }\n return resolved;\n}\n\n/** How many dots a thermostat position's dial label draws — never more than a handful. */\nconst MAX_DOTS_LENGTH = 5;\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`, 30);\n const dots = typeof raw.dots === \"string\" ? raw.dots : \"\";\n if (dots.length > MAX_DOTS_LENGTH) {\n fail(`iron.settings[${index}].dots must be at most ${MAX_DOTS_LENGTH} characters`);\n }\n return {\n key,\n dots,\n label: text(raw.label, `iron.settings[${index}].label`, 20),\n detail: text(raw.detail, `iron.settings[${index}].detail`, 60, \"\"),\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\", 60),\n capacity: text(washerRaw.capacity, \"washer.capacity\", 20, \"\"),\n programs: stringList(washerRaw.programs, \"washer.programs\", 2, 32),\n temperatures: stringList(washerRaw.temperatures, \"washer.temperatures\", 1, 12),\n spins: stringList(washerRaw.spins, \"washer.spins\", 1, 10),\n options: stringList(washerRaw.options ?? [], \"washer.options\", 0, 20),\n },\n iron: {\n name: text(ironRaw.name, \"iron.name\", 60),\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 /** @maxLength 60 */\n clothingType: string;\n /** @maxLength 200 */\n detergent: string;\n fabricSoftener: boolean;\n temperature: string;\n spin: string;\n /** @maxLength 12 */\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 * @maxLength 400\n */\n ironingNotes: string;\n /** Thermostat position. Empty when `ironing` is false. */\n ironSetting: string;\n /** @maxLength 150 */\n drying: string;\n colourGroup: ColourGroup;\n mixTags: MixTag[];\n /** @maxLength 500 */\n notes: string;\n /**\n * Who to credit for a care instruction that isn't obvious from the garment\n * itself — \"the label says 40°\" doesn't need one, \"the manufacturer says\n * wash these alone\" might. Empty when there's nothing to cite.\n * @maxLength 80\n */\n referenceName: string;\n /**\n * A link backing up `referenceName`. Empty when there's nothing to cite.\n * @maxLength 2048\n */\n referenceLink: 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 \"reference_name\",\n \"reference_link\",\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\n/**\n * Caps free-text fields the PDFs render, so a value long enough to visibly\n * crowd a card or reference-sheet row is rejected here rather than in a\n * layout that only degrades quietly. Limits from @washy-washy/pdf's actual\n * fixed-width slots and wrap-safety analysis, not a guess.\n */\nfunction maxLength(row: number, column: string, value: string, max: number): string {\n if (value.length > max) {\n throw new RowError(row, column, `must be at most ${max} characters, found ${value.length}`);\n }\n return value;\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\nconst DURATION_PATTERN = /^~?\\d+:[0-5]\\d$/;\n\n/** Empty stays empty — some piles genuinely have no duration on record. */\nfunction duration(row: number, column: string, value: string): string {\n if (value === \"\") return value;\n if (!DURATION_PATTERN.test(value)) {\n throw new RowError(row, column, `must match H:MM, found \"${value}\"`);\n }\n return maxLength(row, column, value, 12);\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 = maxLength(row, \"clothing_type\", (record.clothing_type ?? \"\").trim(), 60);\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: maxLength(row, \"detergent\", record.detergent ?? \"\", 200),\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: duration(row, \"duration\", record.duration ?? \"\"),\n program: oneOf(row, \"program\", record.program ?? \"\", washer.programs),\n options,\n ironing,\n ironingNotes: maxLength(row, \"ironing_notes\", record.ironing_notes ?? \"\", 400),\n ironSetting,\n drying: maxLength(row, \"drying\", record.drying ?? \"\", 150),\n colourGroup: oneOf<ColourGroup>(row, \"colour_group\", record.colour_group ?? \"\", colourGroups),\n mixTags: tags,\n notes: maxLength(row, \"notes\", record.notes ?? \"\", 500),\n referenceName: maxLength(row, \"reference_name\", record.reference_name ?? \"\", 80),\n referenceLink: maxLength(row, \"reference_link\", record.reference_link ?? \"\", 2048),\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 reference_name: instruction.referenceName,\n reference_link: instruction.referenceLink,\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":";AAgDA,SAAS,KAAK,MAAqB;CACjC,MAAM,IAAI,MAAM,YAAY,MAAM;AACpC;AAEA,SAAS,WAAW,OAAgB,OAAe,SAAiB,WAA6B;CAC/F,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,MAAM,WAAW,KAAK,MAAM,UAAU,MAAM,SAAS,SAAS;CAC9D,IAAI,aAAa,KAAA,GACf,KAAK,GAAG,MAAM,2BAA2B,UAAU,sBAAsB,SAAS,EAAE;CAEtF,OAAO;AACT;AAEA,SAAS,KAAK,OAAgB,OAAe,WAAmB,UAA2B;CACzF,MAAM,WACJ,OAAO,UAAU,YAAY,UAAU,KACnC,QACA,aAAa,KAAA,IACX,WACA,KAAK,GAAG,MAAM,4BAA4B;CAClD,IAAI,SAAS,SAAS,WACpB,KAAK,GAAG,MAAM,m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