@washy-washy/core 1.2.0 → 1.3.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 +8 -1
- package/dist/browser.d.mts +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{mixing-DHXHkb3X.mjs → mixing-Dt043zmh.mjs} +10 -4
- package/dist/mixing-Dt043zmh.mjs.map +1 -0
- package/dist/{rows-BawMuBGc.d.mts → rows-Bn1LlIaD.d.mts} +10 -2
- package/package.json +1 -1
- package/schema/config.schema.json +11 -1
- package/dist/mixing-DHXHkb3X.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -62,6 +62,10 @@ const instructions = chartFromJson(jsonFromStorage, machine);
|
|
|
62
62
|
|
|
63
63
|
### What's in it
|
|
64
64
|
|
|
65
|
+
- Every chart row carries an optional `referenceName`/`referenceLink` pair —
|
|
66
|
+
who to credit for a care instruction that isn't obvious from the garment
|
|
67
|
+
itself ("the manufacturer says wash these alone"), and a link backing it
|
|
68
|
+
up. Both are empty strings when there's nothing to cite.
|
|
65
69
|
- **`parseMachine`** validates a machine description (washer programmes,
|
|
66
70
|
temperatures, spins, options; iron thermostat positions) and hands back a
|
|
67
71
|
typed `Machine`. Every failure names the field that's wrong.
|
|
@@ -74,7 +78,10 @@ const instructions = chartFromJson(jsonFromStorage, machine);
|
|
|
74
78
|
`configToJson`'s output leads with a `$schema` key
|
|
75
79
|
([`schema/config.schema.json`](schema/config.schema.json), generated from
|
|
76
80
|
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.
|
|
81
|
+
among them, validates and autocompletes the file with no setup. The output
|
|
82
|
+
is plain `JSON.stringify(..., null, 2)` — if you write it straight to a
|
|
83
|
+
file in a Biome- or Prettier-linted repo, run your own formatter over it
|
|
84
|
+
afterward, since a generic serializer can't match either tool's opinions.
|
|
78
85
|
- **`mixBlocker`**/**`canMix`**/**`resolve`** decide whether two piles of
|
|
79
86
|
laundry can share a drum, and why not when they can't.
|
|
80
87
|
- **`cardGroups`**/**`washGroups`**/**`ironGroups`** group instructions the
|
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 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-
|
|
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-Bn1LlIaD.mjs";
|
|
2
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 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-
|
|
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-Dt043zmh.mjs";
|
|
2
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,4 +1,4 @@
|
|
|
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-
|
|
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-Bn1LlIaD.mjs";
|
|
2
2
|
//#region src/csv.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Parses the instruction CSV. See `instructionsFromRows` for the row rules.
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-Dt043zmh.mjs";
|
|
2
2
|
import { parse } from "csv-parse/sync";
|
|
3
3
|
//#region src/csv.ts
|
|
4
4
|
/**
|
|
@@ -166,7 +166,9 @@ const COLUMNS = [
|
|
|
166
166
|
"drying",
|
|
167
167
|
"colour_group",
|
|
168
168
|
"mix_tags",
|
|
169
|
-
"notes"
|
|
169
|
+
"notes",
|
|
170
|
+
"reference_name",
|
|
171
|
+
"reference_link"
|
|
170
172
|
];
|
|
171
173
|
var RowError = class extends Error {
|
|
172
174
|
constructor(row, column, message) {
|
|
@@ -242,7 +244,9 @@ function instructionsFromRows(rows, machine) {
|
|
|
242
244
|
drying: record.drying ?? "",
|
|
243
245
|
colourGroup: oneOf(row, "colour_group", record.colour_group ?? "", colourGroups),
|
|
244
246
|
mixTags: tags,
|
|
245
|
-
notes: record.notes ?? ""
|
|
247
|
+
notes: record.notes ?? "",
|
|
248
|
+
referenceName: record.reference_name ?? "",
|
|
249
|
+
referenceLink: record.reference_link ?? ""
|
|
246
250
|
};
|
|
247
251
|
});
|
|
248
252
|
}
|
|
@@ -270,7 +274,9 @@ function rowsFromInstructions(instructions) {
|
|
|
270
274
|
drying: instruction.drying,
|
|
271
275
|
colour_group: instruction.colourGroup,
|
|
272
276
|
mix_tags: instruction.mixTags.join("|"),
|
|
273
|
-
notes: instruction.notes
|
|
277
|
+
notes: instruction.notes,
|
|
278
|
+
reference_name: instruction.referenceName,
|
|
279
|
+
reference_link: instruction.referenceLink
|
|
274
280
|
}));
|
|
275
281
|
}
|
|
276
282
|
/**
|
|
@@ -541,4 +547,4 @@ function ironGroups(instructions, order) {
|
|
|
541
547
|
//#endregion
|
|
542
548
|
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 };
|
|
543
549
|
|
|
544
|
-
//# sourceMappingURL=mixing-
|
|
550
|
+
//# sourceMappingURL=mixing-Dt043zmh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixing-Dt043zmh.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 * 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 */\n referenceName: string;\n /** A link backing up `referenceName`. Empty when there's nothing to cite. */\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\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 referenceName: record.reference_name ?? \"\",\n referenceLink: record.reference_link ?? \"\",\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":";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,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AI,KAAM,EAAE,EAAE,CAAO,WAAW,CACxE;AACF"}
|
|
@@ -121,6 +121,14 @@ interface Instruction {
|
|
|
121
121
|
colourGroup: ColourGroup;
|
|
122
122
|
mixTags: MixTag[];
|
|
123
123
|
notes: string;
|
|
124
|
+
/**
|
|
125
|
+
* Who to credit for a care instruction that isn't obvious from the garment
|
|
126
|
+
* itself — "the label says 40°" doesn't need one, "the manufacturer says
|
|
127
|
+
* wash these alone" might. Empty when there's nothing to cite.
|
|
128
|
+
*/
|
|
129
|
+
referenceName: string;
|
|
130
|
+
/** A link backing up `referenceName`. Empty when there's nothing to cite. */
|
|
131
|
+
referenceLink: string;
|
|
124
132
|
}
|
|
125
133
|
/** An instruction plus the other piles it may share a drum with. */
|
|
126
134
|
interface ResolvedInstruction extends Instruction {
|
|
@@ -293,7 +301,7 @@ declare function washGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
|
293
301
|
declare function ironGroups<T extends Instruction>(instructions: T[], order: readonly string[]): T[][];
|
|
294
302
|
//#endregion
|
|
295
303
|
//#region src/rows.d.ts
|
|
296
|
-
declare const COLUMNS: readonly ["clothing_type", "detergent", "fabric_softener", "temperature", "spin", "duration", "program", "options", "ironing", "ironing_notes", "iron_setting", "drying", "colour_group", "mix_tags", "notes"];
|
|
304
|
+
declare const COLUMNS: readonly ["clothing_type", "detergent", "fabric_softener", "temperature", "spin", "duration", "program", "options", "ironing", "ironing_notes", "iron_setting", "drying", "colour_group", "mix_tags", "notes", "reference_name", "reference_link"];
|
|
297
305
|
/** One row, keyed the same way as a CSV column and the chart's JSON Schema. */
|
|
298
306
|
type Row = Record<(typeof COLUMNS)[number], string>;
|
|
299
307
|
declare class RowError extends Error {
|
|
@@ -344,4 +352,4 @@ declare function chartToJson(instructions: Instruction[]): string;
|
|
|
344
352
|
declare function chartFromJson(source: string, machine: Machine): Instruction[];
|
|
345
353
|
//#endregion
|
|
346
354
|
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-
|
|
355
|
+
//# sourceMappingURL=rows-Bn1LlIaD.d.mts.map
|
package/package.json
CHANGED
|
@@ -75,6 +75,14 @@
|
|
|
75
75
|
"program": {
|
|
76
76
|
"type": "string"
|
|
77
77
|
},
|
|
78
|
+
"referenceLink": {
|
|
79
|
+
"description": "A link backing up `referenceName`. Empty when there's nothing to cite.",
|
|
80
|
+
"type": "string"
|
|
81
|
+
},
|
|
82
|
+
"referenceName": {
|
|
83
|
+
"description": "Who to credit for a care instruction that isn't obvious from the garment itself — \"the label says 40°\" doesn't need one, \"the manufacturer says wash these alone\" might. Empty when there's nothing to cite.",
|
|
84
|
+
"type": "string"
|
|
85
|
+
},
|
|
78
86
|
"spin": {
|
|
79
87
|
"type": "string"
|
|
80
88
|
},
|
|
@@ -97,7 +105,9 @@
|
|
|
97
105
|
"drying",
|
|
98
106
|
"colourGroup",
|
|
99
107
|
"mixTags",
|
|
100
|
-
"notes"
|
|
108
|
+
"notes",
|
|
109
|
+
"referenceName",
|
|
110
|
+
"referenceLink"
|
|
101
111
|
],
|
|
102
112
|
"type": "object"
|
|
103
113
|
},
|
|
@@ -1 +0,0 @@
|
|
|
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;A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