@gohcltech/edge-print-client 2.0.61-develop → 2.0.71-develop

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 CHANGED
@@ -119,10 +119,38 @@ Each `PrinterInfo` object includes:
119
119
  | `duplex` | `boolean?` | `true` if the printer supports double-sided printing |
120
120
  | `trays` | `TrayInfo[]?` | Input trays/bins (see below) |
121
121
  | `papers` | `string[]?` | All supported paper sizes (e.g. `["Letter", "A4"]`) |
122
+ | `mediaTypes` | `string[]?` | Stock types the driver reports (e.g. `["Plain", "Bond"]`). Absent for most printers — see below |
122
123
  | `copiesMax` | `number?` | Maximum copies the driver accepts in one job |
123
124
  | `orientations` | `string[]?` | Supported orientations (e.g. `["portrait", "landscape"]`) |
124
125
  | `virtualPrinter` | `boolean?` | `true` for Developer (virtual) printers injected by the agent |
125
126
 
127
+ **On `paperSize`, `tray` and `mediaType`.** A value the printer does not
128
+ recognise now rejects the job rather than printing on the driver's default —
129
+ the substitution this release exists to remove. Three things soften it:
130
+
131
+ - **Only when the printer actually said.** If `papers`, `trays` or `mediaTypes`
132
+ is absent, the agent could not determine that capability and accepts whatever
133
+ you ask, with a `capability_unverified` warning on the response. Many printers
134
+ report nothing at all, so this is the common case.
135
+ - **Matching ignores case.** `"letter"` is accepted for `"Letter"`.
136
+ - **The rejection tells you what would work.** `unsupported_value` carries
137
+ `field` and a `supported` array of the printer's real values.
138
+
139
+ `paperSize` and `tray` are only checked on paths that can apply them; `raw`,
140
+ `html` and network targets never did, so they are left alone rather than
141
+ starting to fail.
142
+
143
+ **On `mediaTypes`.** The field is usually absent. Of eleven drivers surveyed,
144
+ eight listed no stock types at all, and a ninth listed them only under a
145
+ vendor-private key whose values are the driver's internal codes rather than
146
+ names you could choose from — the agent reports nothing in that case too. When
147
+ the field is absent the agent accepts whatever stock you ask for rather than
148
+ guessing. When it *is*
149
+ present the strings are the driver's own and are not always self-describing, so
150
+ read them off the target machine (the agent's Printers tab lists them) rather
151
+ than assuming a vocabulary. Passing a value the printer does not list rejects
152
+ with `unsupported_value`, and the error's `supported` array names the real ones.
153
+
126
154
  1.x agents sent `is_default`, `share_name`, `copies_max` and `virtual_printer`.
127
155
  Those spellings are still accepted on read and mapped onto the camelCase fields
128
156
  above, so nothing downstream sees the old names. **Removed in 3.0.**
@@ -221,8 +249,9 @@ Two limits worth knowing before you build on this:
221
249
  | `orientation` | `'portrait' \| 'landscape'?` | Page orientation |
222
250
  | `jobName` | `string?` | Name shown in the OS print queue |
223
251
  | `colorType` | `'color' \| 'grayscale' \| 'black-white'?` | Color mode |
224
- | `paperSize` | `string?` | Paper size from `PrinterInfo.papers` (e.g. `"Letter"`) |
225
- | `tray` | `string?` | Tray name from `TrayInfo.name` (e.g. `"Tray 1"`) |
252
+ | `paperSize` | `string?` | Paper size from `PrinterInfo.papers` (e.g. `"Letter"`). Rejects if the printer lists paper sizes and this is not one — see below |
253
+ | `tray` | `string?` | Tray name from `TrayInfo.name` (e.g. `"Tray 1"`). Rejects if the printer lists trays and this is not one — see below |
254
+ | `mediaType` | `string?` | Stock type from `PrinterInfo.mediaTypes` (e.g. `"Bond"`). Rejected for `raw`/`html` content and network targets |
226
255
 
227
256
  **`data`** — `PrintData[]`
228
257
 
@@ -407,11 +436,14 @@ The four codes in the table above are never accepted *from* the agent. A frame
407
436
  claiming `code: "timeout"` is read as `unknown`, so a failure the agent
408
437
  considers final cannot arrive labelled retryable.
409
438
 
410
- Three more are **reserved**: `unsupported_value`, `content_overflow` and
411
- `encrypted_pdf` are part of the closed set and typed here, so code written
412
- today handles them, but no agent sends them yet. `supported` is populated only
413
- by `unsupported_value`, so it is always `undefined` against an agent of this
414
- generation.
439
+ `unsupported_value` is raised when `paperSize`, `tray` or `mediaType` names a
440
+ value the printer does not list, and it is the one code that populates
441
+ `supported` — read that array rather than parsing the message, and offer the
442
+ values it names.
443
+
444
+ Two more are still **reserved**: `content_overflow` and `encrypted_pdf` are part
445
+ of the closed set and typed here, so code written today handles them, but no
446
+ agent sends them yet.
415
447
 
416
448
  And `unknown`, the fallback for a code this client does not recognise — which
417
449
  is what lets a client built today keep working against a future agent. Treat an
@@ -58,14 +58,34 @@ export interface PrintConfig {
58
58
  /**
59
59
  * Paper size, exactly as returned by {@link PrinterInfo.papers}
60
60
  * (e.g. `"Letter"`, `"A4"`). Omit to use the printer's current default.
61
+ *
62
+ * Rejects with `unsupported_value` when the printer lists paper sizes and
63
+ * this is not one of them — the error's `supported` array names the real
64
+ * ones. A printer that lists none accepts anything, with a
65
+ * `capability_unverified` warning. Matching ignores case.
61
66
  */
62
67
  paperSize?: string;
63
68
  /**
64
69
  * Input tray, exactly as returned by {@link TrayInfo.name} inside
65
70
  * {@link PrinterInfo.trays} (e.g. `"Tray 1"`, `"Auto"`).
66
71
  * Omit to use the printer's current default.
72
+ *
73
+ * Rejects with `unsupported_value` when the printer lists trays and this is
74
+ * not one of them — the error's `supported` array names the real ones. A
75
+ * printer that lists none accepts anything, with a `capability_unverified`
76
+ * warning. Matching ignores case.
67
77
  */
68
78
  tray?: string;
79
+ /**
80
+ * Media / stock type, exactly as returned by {@link PrinterInfo.mediaTypes}
81
+ * (e.g. `"Plain"`, `"Bond"`, `"Thermal"`). Changes how the printer feeds and
82
+ * fuses the page. Omit to use the printer's current default.
83
+ *
84
+ * Not supported for `raw` or `html` content, or a network target — those
85
+ * paths never reach the printer's driver. Requesting it there rejects with
86
+ * `unsupported_for_path`.
87
+ */
88
+ mediaType?: string;
69
89
  }
70
90
  /**
71
91
  * A single unit of content to be printed.
@@ -178,6 +198,18 @@ export interface PrinterInfo {
178
198
  * Pass one of these values to {@link PrintConfig.paperSize}.
179
199
  */
180
200
  papers?: string[];
201
+ /**
202
+ * Stock types the driver reports — card stock, labels, envelopes and so on.
203
+ * Pass one of these values to {@link PrintConfig.mediaType}.
204
+ *
205
+ * Absent for most printers — many drivers report no stock types, and some
206
+ * report them only under a vendor-private key whose values are internal
207
+ * codes rather than choosable names. The agent reports nothing in either
208
+ * case and then accepts whatever is asked rather than guessing. When the
209
+ * field *is* present, the strings are the driver's own and may not be
210
+ * self-describing.
211
+ */
212
+ mediaTypes?: string[];
181
213
  /** Maximum number of copies the driver accepts in a single job. */
182
214
  copiesMax?: number;
183
215
  /** Page orientations the driver supports (e.g. `["portrait", "landscape"]`). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gohcltech/edge-print-client",
3
- "version": "2.0.61-develop",
3
+ "version": "2.0.71-develop",
4
4
  "description": "Browser client for the Edge Printing WebSocket agent",
5
5
  "license": "MIT",
6
6
  "repository": {