@washy-washy/core 1.6.3 → 2.0.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 +26 -31
- package/dist/index.d.mts +364 -8
- package/dist/index.mjs +569 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +24 -22
- package/schema/config.schema.json +2 -2
- package/dist/browser.d.mts +0 -2
- package/dist/browser.mjs +0 -2
- package/dist/mixing-DEthnE5k.mjs +0 -585
- package/dist/mixing-DEthnE5k.mjs.map +0 -1
- package/dist/rows-DuLRhKiW.d.mts +0 -383
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
Chart parsing, machine validation, and mixing rules for
|
|
10
10
|
[washy-washy](https://github.com/alrayyes/washy-washy-cli), a laundry chart
|
|
11
11
|
generator. This package holds no rendering or file I/O — just the pure logic
|
|
12
|
-
a
|
|
12
|
+
a chart is checked and reasoned about with, shared by the CLI, the
|
|
13
13
|
web app, and [`@washy-washy/pdf`](https://github.com/alrayyes/washy-washy-pdf).
|
|
14
14
|
|
|
15
|
-
**Jump to:** [
|
|
15
|
+
**Jump to:** [Usage](#usage) · [Coming from CSV](#coming-from-csv) ·
|
|
16
16
|
[What's in it](#whats-in-it) · [Development](#development) ·
|
|
17
17
|
[API reference](https://alrayyes.github.io/washy-washy-core/)
|
|
18
18
|
|
|
@@ -29,45 +29,40 @@ web app, and [`@washy-washy/pdf`](https://github.com/alrayyes/washy-washy-pdf).
|
|
|
29
29
|
npm install @washy-washy/core
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
## Two entry points
|
|
33
|
-
|
|
34
|
-
| Import | Use when | Includes |
|
|
35
|
-
| --------------------------- | --------------------------------- | --------------------------------- |
|
|
36
|
-
| `@washy-washy/core/browser` | Bundled for a browser | Everything except CSV parsing |
|
|
37
|
-
| `@washy-washy/core` | Node/Bun, reading a CSV from disk | Everything, including CSV parsing |
|
|
38
|
-
|
|
39
|
-
`@washy-washy/core`'s CSV parser depends on `csv-parse`, which reaches for
|
|
40
|
-
Node's `Buffer` at import time even if nothing calls it — a bundler ships
|
|
41
|
-
that reference into the client, and it dies at runtime with
|
|
42
|
-
`Buffer is not defined`. `@washy-washy/core/browser` excludes it: a browser
|
|
43
|
-
consumer reads and writes charts as JSON instead (`chartFromJson`/
|
|
44
|
-
`chartToJson`), which needs no such dependency.
|
|
45
|
-
|
|
46
32
|
## Usage
|
|
47
33
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Read and write a chart as JSON instead of CSV — `@washy-washy/core/browser`
|
|
51
|
-
has no CSV parser (see [Two entry points](#two-entry-points)).
|
|
34
|
+
Hand a chart over as JSON, or as rows you've already read from somewhere else.
|
|
52
35
|
|
|
53
36
|
```ts
|
|
54
|
-
import {
|
|
55
|
-
chartFromJson,
|
|
56
|
-
chartToJson,
|
|
57
|
-
parseMachine,
|
|
58
|
-
} from "@washy-washy/core/browser";
|
|
37
|
+
import { chartFromJson, chartToJson, parseMachine } from "@washy-washy/core";
|
|
59
38
|
|
|
60
39
|
const machine = parseMachine(machineConfig);
|
|
61
40
|
const instructions = chartFromJson(jsonFromStorage, machine);
|
|
41
|
+
const json = chartToJson(instructions);
|
|
62
42
|
```
|
|
63
43
|
|
|
64
|
-
|
|
44
|
+
`@washy-washy/core/browser` still works and exports the same thing as
|
|
45
|
+
`@washy-washy/core`. Nothing here needs Node, so either one bundles for a
|
|
46
|
+
browser.
|
|
65
47
|
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
### Coming from CSV
|
|
49
|
+
|
|
50
|
+
Version 2 removed `parseInstructions` and the CSV parser with it. Read the file
|
|
51
|
+
with the parser of your choice and pass the records to `instructionsFromRows`.
|
|
52
|
+
With [`csv-parse`](https://csv.js.org/parse/), these options match what
|
|
53
|
+
`parseInstructions` did:
|
|
68
54
|
|
|
69
|
-
|
|
70
|
-
|
|
55
|
+
```ts
|
|
56
|
+
import { instructionsFromRows } from "@washy-washy/core";
|
|
57
|
+
import { parse } from "csv-parse/sync";
|
|
58
|
+
|
|
59
|
+
const rows: Record<string, string>[] = parse(csvFileContents, {
|
|
60
|
+
bom: true,
|
|
61
|
+
columns: true,
|
|
62
|
+
skip_empty_lines: true,
|
|
63
|
+
trim: true,
|
|
64
|
+
});
|
|
65
|
+
const instructions = instructionsFromRows(rows, machine);
|
|
71
66
|
```
|
|
72
67
|
|
|
73
68
|
### What's in it
|
|
@@ -79,7 +74,7 @@ const instructions = parseInstructions(csvFileContents, machine);
|
|
|
79
74
|
- **`parseMachine`** validates a machine description (washer programmes,
|
|
80
75
|
temperatures, spins, options; iron thermostat positions) and hands back a
|
|
81
76
|
typed `Machine`. Every failure names the field that's wrong.
|
|
82
|
-
- **`
|
|
77
|
+
- **`instructionsFromRows`** (rows) and **`chartFromJson`**/**`chartToJson`**
|
|
83
78
|
(JSON) parse a chart against a `Machine`, rejecting any row that asks for a
|
|
84
79
|
setting the machine doesn't have. `duration` is checked too, against
|
|
85
80
|
`~H:MM` (the `~` is optional) — empty is still fine, for a pile with no
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,370 @@
|
|
|
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
|
-
//#region src/csv.d.ts
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* The appliances a chart is drawn for, as data rather than code.
|
|
3
|
+
*
|
|
4
|
+
* Everything the PDFs render — dial angles, which chips exist, what a valid chart
|
|
5
|
+
* value is — comes from a machine file, so pointing this at a different washing
|
|
6
|
+
* machine is editing JSON rather than editing TypeScript. The labels in that
|
|
7
|
+
* file are copied off the fascia in whatever language it is printed in, and
|
|
8
|
+
* nothing here ever translates them: a chart that says "Cottons" when the dial
|
|
9
|
+
* says "Katoen" is worse than no chart, because you have to translate it back
|
|
10
|
+
* while standing in front of the machine.
|
|
11
|
+
*/
|
|
12
|
+
export interface Washer {
|
|
13
|
+
/** @maxLength 60 */
|
|
14
|
+
name: string;
|
|
15
|
+
/** @maxLength 30 */
|
|
16
|
+
capacity: string;
|
|
17
|
+
/** Dial labels in physical order from twelve o'clock, clockwise. Index is the angle. */
|
|
18
|
+
programs: string[];
|
|
19
|
+
temperatures: string[];
|
|
20
|
+
spins: string[];
|
|
21
|
+
options: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface IronSetting {
|
|
24
|
+
/** @maxLength 30 */
|
|
25
|
+
key: string;
|
|
26
|
+
/** @maxLength 5 */
|
|
27
|
+
dots: string;
|
|
28
|
+
/** @maxLength 20 */
|
|
29
|
+
label: string;
|
|
30
|
+
/** @maxLength 60 */
|
|
31
|
+
detail: string;
|
|
32
|
+
steam: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface Iron {
|
|
35
|
+
/** @maxLength 60 */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Thermostat positions in order, coolest first. */
|
|
38
|
+
settings: IronSetting[];
|
|
39
|
+
}
|
|
40
|
+
export interface Machine {
|
|
41
|
+
washer: Washer;
|
|
42
|
+
iron: Iron;
|
|
43
|
+
}
|
|
44
|
+
/** Longest a single washer.programs dial caption can be. */
|
|
45
|
+
export declare const MAX_WASHER_PROGRAM_LENGTH = 32;
|
|
46
|
+
/**
|
|
47
|
+
* Longest a single washer.temperatures entry can be — the reference sheet's
|
|
48
|
+
* °C column. Raised from 12 once washy-washy-pdf#61 made room (see #36).
|
|
49
|
+
*/
|
|
50
|
+
export declare const MAX_WASHER_TEMPERATURE_LENGTH = 15;
|
|
51
|
+
/** Longest a single washer.spins entry can be. */
|
|
52
|
+
export declare const MAX_WASHER_SPIN_LENGTH = 10;
|
|
53
|
+
/** Longest a single washer.options chip can be. */
|
|
54
|
+
export declare const MAX_WASHER_OPTION_LENGTH = 20;
|
|
55
|
+
/**
|
|
56
|
+
* Checks a parsed machine file and hands back something the renderer can use.
|
|
57
|
+
* Every failure names the field, because the fix is always an edit to that
|
|
58
|
+
* line of JSON.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const machine = parseMachine(JSON.parse(machineFileContents));
|
|
63
|
+
* machine.washer.programs; // ["Off", "Cottons", "Wool", ...]
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function parseMachine(value: unknown): Machine;
|
|
67
|
+
/**
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* ironSetting(machine, "2")?.label; // "••"
|
|
71
|
+
* ironSetting(machine, "nope"); // undefined
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function ironSetting(machine: Machine, key: string): IronSetting | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The keys a row may write in `iron_setting`, coolest first.
|
|
77
|
+
*
|
|
78
|
+
* There is no key for "do not iron". That is the `ironing` column's job, and
|
|
79
|
+
* two places to say the same thing is two places to disagree.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* ironSettingKeys(machine); // ["min", "1", "2", "3"]
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function ironSettingKeys(machine: Machine): string[];
|
|
87
|
+
/**
|
|
88
|
+
* `40` becomes `40°`; `cold` stays `cold`. The machine file is free to use
|
|
89
|
+
* whatever word its display shows for the cold wash, so the degree sign is
|
|
90
|
+
* decided by whether the value is a number rather than by a list of exceptions.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* formatTemperature("40"); // "40°"
|
|
95
|
+
* formatTemperature("cold"); // "cold"
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function formatTemperature(value: string): string;
|
|
99
|
+
/** Which pile a garment belongs to on colour grounds. `any` mixes with all. */
|
|
100
|
+
export declare const colourGroups: readonly ["white", "colour", "dark", "sport", "any"];
|
|
101
|
+
export type ColourGroup = (typeof colourGroups)[number];
|
|
102
|
+
/**
|
|
103
|
+
* Reasons two piles might not belong together even when the machine settings
|
|
104
|
+
* agree. See `canMix` in `mixing.ts` for how each one is applied.
|
|
105
|
+
*/
|
|
106
|
+
export declare const mixTags: readonly ["lint-shedder", "lint-magnet", "dye-bleeder", "solo"];
|
|
107
|
+
export type MixTag = (typeof mixTags)[number];
|
|
108
|
+
/**
|
|
109
|
+
* One chart row: everything needed to wash, iron and dry one pile of laundry.
|
|
110
|
+
*
|
|
111
|
+
* The machine-facing fields are plain strings rather than unions, because what
|
|
112
|
+
* counts as valid depends on the machine file you point this at. `rows.ts`
|
|
113
|
+
* checks each of them against that machine as it parses, so nothing downstream
|
|
114
|
+
* has to wonder whether a programme name exists.
|
|
115
|
+
*/
|
|
116
|
+
export interface Instruction {
|
|
117
|
+
/** @maxLength 60 */
|
|
118
|
+
clothingType: string;
|
|
119
|
+
/** @maxLength 200 */
|
|
120
|
+
detergent: string;
|
|
121
|
+
fabricSoftener: boolean;
|
|
122
|
+
temperature: string;
|
|
123
|
+
spin: string;
|
|
124
|
+
/** @maxLength 12 */
|
|
125
|
+
duration: string;
|
|
126
|
+
program: string;
|
|
127
|
+
options: string[];
|
|
128
|
+
/** Whether this pile gets ironed at all. */
|
|
129
|
+
ironing: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* How to iron it, or why you don't. Free prose and often empty, because most
|
|
132
|
+
* of what there is to say about a pile nobody irons is already said by
|
|
133
|
+
* `ironing` being false.
|
|
134
|
+
* @maxLength 400
|
|
135
|
+
*/
|
|
136
|
+
ironingNotes: string;
|
|
137
|
+
/** Thermostat position. Empty when `ironing` is false. */
|
|
138
|
+
ironSetting: string;
|
|
139
|
+
/** @maxLength 230 */
|
|
140
|
+
drying: string;
|
|
141
|
+
colourGroup: ColourGroup;
|
|
142
|
+
mixTags: MixTag[];
|
|
143
|
+
/** @maxLength 570 */
|
|
144
|
+
notes: string;
|
|
145
|
+
/**
|
|
146
|
+
* Who to credit for a care instruction that isn't obvious from the garment
|
|
147
|
+
* itself — "the label says 40°" doesn't need one, "the manufacturer says
|
|
148
|
+
* wash these alone" might. Empty when there's nothing to cite.
|
|
149
|
+
* @maxLength 80
|
|
150
|
+
*/
|
|
151
|
+
referenceName: string;
|
|
152
|
+
/**
|
|
153
|
+
* A link backing up `referenceName`. Empty when there's nothing to cite.
|
|
154
|
+
* @maxLength 2048
|
|
155
|
+
*/
|
|
156
|
+
referenceLink: string;
|
|
157
|
+
}
|
|
158
|
+
/** An instruction plus the other piles it may share a drum with. */
|
|
159
|
+
export interface ResolvedInstruction extends Instruction {
|
|
160
|
+
mixesWith: string[];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* How long a card or a load is going to tie the machine up.
|
|
164
|
+
*
|
|
165
|
+
* Usually one figure. Piles sharing a load agree on every setting, so they
|
|
166
|
+
* ought to agree on this too — but the chart is data somebody types, and
|
|
167
|
+
* printing both is more honest than picking the first one and hoping.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* durationsOf([pile, pile]); // "~2:00"
|
|
172
|
+
* durationsOf([pile, { ...pile, duration: "~1:10" }]); // "~2:00 / ~1:10"
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export declare function durationsOf(group: Instruction[]): string;
|
|
176
|
+
/**
|
|
177
|
+
* Which sheet to draw.
|
|
178
|
+
*
|
|
179
|
+
* `full` is the whole chart. The other two are the same chart cut where the
|
|
180
|
+
* work is: washing happens in front of the machine on a Sunday morning, ironing
|
|
181
|
+
* happens at a board on a Wednesday evening, and neither job wants to read past
|
|
182
|
+
* the other's advice to find its own.
|
|
183
|
+
*/
|
|
184
|
+
export declare const variants: readonly ["full", "wash", "iron"];
|
|
185
|
+
export type Variant = (typeof variants)[number];
|
|
186
|
+
/**
|
|
187
|
+
* Where `configToJson` points editors at the real JSON Schema (generated
|
|
188
|
+
* from the `Config` type — see `schema/config.schema.json` and `bun run
|
|
189
|
+
* schema`). Unpinned to the package's `latest` npm tag rather than the
|
|
190
|
+
* running version, matching how most `$schema` URLs work: close enough,
|
|
191
|
+
* without needing a build-time read of this package's own `package.json`.
|
|
192
|
+
*/
|
|
193
|
+
export declare const CONFIG_SCHEMA_URL = "https://cdn.jsdelivr.net/npm/@washy-washy/core/schema/config.schema.json";
|
|
194
|
+
/**
|
|
195
|
+
* The washing machine and the chart that describes it, in one place. Both
|
|
196
|
+
* halves are exactly what `parseMachine`/`instructionsFromRows` already
|
|
197
|
+
* produce — this is a wrapper around the pair, not a third shape.
|
|
198
|
+
*/
|
|
199
|
+
export interface Config {
|
|
200
|
+
machine: Machine;
|
|
201
|
+
chart: Instruction[];
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Validates a `{ machine, chart }` object, checking the chart against the
|
|
205
|
+
* machine it's embedded with — never a different one. Every failure names
|
|
206
|
+
* which half is wrong, same as `parseMachine` and `instructionsFromRows` do
|
|
207
|
+
* on their own.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const config = parseConfig(JSON.parse(configFileContents));
|
|
212
|
+
* config.machine.washer.name; // "Generic front loader"
|
|
213
|
+
* config.chart[0].clothingType; // "Dark"
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export declare function parseConfig(value: unknown): Config;
|
|
217
|
+
/**
|
|
218
|
+
* The reverse of `parseConfig` — what a JSON export writes out. Leads with a
|
|
219
|
+
* `$schema` key so an editor that reads it (VS Code among them) validates
|
|
220
|
+
* and autocompletes the file without the person editing it doing anything.
|
|
221
|
+
* `parseConfig` ignores the key on the way back in — it never asks for
|
|
222
|
+
* anything beyond `machine` and `chart`.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* const json = configToJson(config);
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
export declare function configToJson(config: Config): string;
|
|
230
|
+
/**
|
|
231
|
+
* The other half of `configToJson`. Throws the same errors `parseConfig` does.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* const config = configFromJson(configFileContents);
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
export declare function configFromJson(source: string): Config;
|
|
239
|
+
/** Why two piles cannot share a drum. `null` means they can. */
|
|
240
|
+
export type Blocker = "solo" | "settings" | "colour" | "lint";
|
|
241
|
+
export declare const blockerLegend: Record<Blocker, string>;
|
|
242
|
+
/** Short codes used in the compatibility matrix, so a cell stays one glyph. */
|
|
243
|
+
export declare const blockerCode: Record<Blocker, string>;
|
|
244
|
+
/**
|
|
245
|
+
* Decides whether two piles can go in the drum together, and if not, why.
|
|
246
|
+
*
|
|
247
|
+
* The order matters: the reason reported is the one you would want to hear
|
|
248
|
+
* first. "Wash it alone" beats "the spin speed differs", because changing the
|
|
249
|
+
* spin speed would not help.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* mixBlocker(towels, socks); // "lint" — towels shed onto everything else
|
|
254
|
+
* mixBlocker(socks, socks2); // null — nothing stops them sharing a drum
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
export declare function mixBlocker(a: Instruction, b: Instruction): Blocker | null;
|
|
258
|
+
/**
|
|
259
|
+
* @example
|
|
260
|
+
* ```ts
|
|
261
|
+
* canMix(towels, socks); // false
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
export declare function canMix(a: Instruction, b: Instruction): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Annotates each instruction with the other piles it may share a load with.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* resolve(instructions)[0].mixesWith; // ["Socks", "Jeans"]
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
export declare function resolve(instructions: Instruction[]): ResolvedInstruction[];
|
|
274
|
+
/**
|
|
275
|
+
* Groups piles that can all be washed together — every member compatible with
|
|
276
|
+
* every other, not merely with the first one it met.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```ts
|
|
280
|
+
* loadGroups(instructions); // [[towels], [socks, jeans], [wool]]
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
export declare function loadGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
284
|
+
/**
|
|
285
|
+
* Piles you set the machine and the iron up for identically. Every dial
|
|
286
|
+
* drawing on their cards would be the same drawing, so they get one card
|
|
287
|
+
* listing all the names.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* cardGroups(instructions).map((group) => group.map((item) => item.clothingType));
|
|
292
|
+
* // [["Socks", "Jeans"], ["Towels"]]
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
export declare function cardGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
296
|
+
/**
|
|
297
|
+
* The same, for a sheet with no iron on it. Dark, Black Socks and Denim each
|
|
298
|
+
* need their own card on the full chart only because they want three different
|
|
299
|
+
* thermostat positions; standing at the machine they are one wash.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* washGroups(instructions); // merges piles cardGroups would have split on iron settings alone
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
export declare function washGroups<T extends Instruction>(instructions: T[]): T[][];
|
|
307
|
+
/**
|
|
308
|
+
* Piles by where the iron's thermostat points, coolest first.
|
|
309
|
+
*
|
|
310
|
+
* An ironing sheet is read the other way round from a washing one. You do not
|
|
311
|
+
* fetch a pile and look up its setting — you set the iron once and work through
|
|
312
|
+
* everything that goes at that heat, so the thermostat position is the heading
|
|
313
|
+
* and the piles are the list under it. `order` is `ironSettingKeys`; a pile you
|
|
314
|
+
* never iron has no position in it and sorts last, which is right — it is the
|
|
315
|
+
* pile you never pick up.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* ironGroups(instructions, ironSettingKeys(machine));
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
export declare function ironGroups<T extends Instruction>(instructions: T[], order: readonly string[]): T[][];
|
|
323
|
+
export 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"];
|
|
324
|
+
/** One row, keyed the same way as the chart's JSON Schema. */
|
|
325
|
+
export type Row = Record<(typeof COLUMNS)[number], string>;
|
|
326
|
+
export declare class RowError extends Error {
|
|
327
|
+
constructor(row: number, column: string, message: string);
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Checks rows shaped like the chart's schema, such as a JSON file
|
|
331
|
+
* round-tripped through `rowsFromInstructions`, against what the appliances in the machine file can actually be set to. A typo in a
|
|
332
|
+
* programme name fails here rather than producing a PDF that tells you to turn
|
|
333
|
+
* the dial to a position that does not exist — and so does a chart written for
|
|
334
|
+
* a different machine than the one you passed.
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* const instructions = instructionsFromRows(JSON.parse(jsonFromStorage), machine);
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
export declare function instructionsFromRows(rows: Record<string, string>[], machine: Machine): Instruction[];
|
|
342
|
+
/**
|
|
343
|
+
* The reverse of `instructionsFromRows` — what a JSON export writes out.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* const rows = rowsFromInstructions(instructions);
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
export declare function rowsFromInstructions(instructions: Instruction[]): Row[];
|
|
351
|
+
/**
|
|
352
|
+
* The JSON interchange format for a chart — the same row shape
|
|
353
|
+
* a chart's JSON Schema describes, so a file written here validates against
|
|
354
|
+
* it.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```ts
|
|
358
|
+
* const json = chartToJson(instructions);
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
export declare function chartToJson(instructions: Instruction[]): string;
|
|
362
|
+
/**
|
|
363
|
+
* The other half of `chartToJson`. Throws the same errors `instructionsFromRows` does.
|
|
5
364
|
*
|
|
6
365
|
* @example
|
|
7
366
|
* ```ts
|
|
8
|
-
* const instructions =
|
|
367
|
+
* const instructions = chartFromJson(jsonFromStorage, machine);
|
|
9
368
|
* ```
|
|
10
369
|
*/
|
|
11
|
-
export declare function
|
|
12
|
-
//#endregion
|
|
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, parseMachine, resolve, rowsFromInstructions, variants, washGroups };
|
|
14
|
-
//# sourceMappingURL=index.d.mts.map
|
|
370
|
+
export declare function chartFromJson(source: string, machine: Machine): Instruction[];
|