sane-wasm 0.3.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/libsane.js +2 -2
- package/build/libsane.wasm +0 -0
- package/dist/index.d.ts +4 -4
- package/dist/readers.d.ts +2 -2
- package/dist/readers.js +33 -35
- package/package.json +1 -1
package/build/libsane.js
CHANGED
|
@@ -137,8 +137,8 @@ Module["ready"] = new Promise((resolve, reject) => {
|
|
|
137
137
|
sane_control_option_get_value: true,
|
|
138
138
|
sane_control_option_set_value: true,
|
|
139
139
|
sane_control_option_set_auto: true,
|
|
140
|
-
sane_get_parameters:
|
|
141
|
-
sane_start:
|
|
140
|
+
sane_get_parameters: true,
|
|
141
|
+
sane_start: true,
|
|
142
142
|
sane_read: true,
|
|
143
143
|
sane_cancel: true,
|
|
144
144
|
sane_strstatus: false
|
package/build/libsane.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -360,20 +360,20 @@ export interface LibSANE {
|
|
|
360
360
|
* Equivalent to the SANE API C function `sane_get_parameters`.
|
|
361
361
|
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-get-parameters}
|
|
362
362
|
*/
|
|
363
|
-
sane_get_parameters: () => {
|
|
363
|
+
sane_get_parameters: () => Promise<{
|
|
364
364
|
status: SANEStatus.GOOD;
|
|
365
365
|
parameters: SANEParameters;
|
|
366
366
|
} | {
|
|
367
367
|
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
368
368
|
parameters: null;
|
|
369
|
-
}
|
|
369
|
+
}>;
|
|
370
370
|
/**
|
|
371
371
|
* Equivalent to the SANE API C function `sane_start`.
|
|
372
372
|
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-start}
|
|
373
373
|
*/
|
|
374
|
-
sane_start: () => {
|
|
374
|
+
sane_start: () => Promise<{
|
|
375
375
|
status: SANEStatus;
|
|
376
|
-
}
|
|
376
|
+
}>;
|
|
377
377
|
/**
|
|
378
378
|
* Equivalent to the SANE API C function `sane_read`.
|
|
379
379
|
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-read}
|
package/dist/readers.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare class ScanDataReader<T extends ScanDataReaderEventMap = ScanDataR
|
|
|
52
52
|
/**
|
|
53
53
|
* Start scanning operation.
|
|
54
54
|
*/
|
|
55
|
-
start(): {
|
|
55
|
+
start(): Promise<{
|
|
56
56
|
status: SANEStatus.UNSUPPORTED | SANEStatus.CANCELLED | SANEStatus.DEVICE_BUSY | SANEStatus.INVAL | SANEStatus.EOF | SANEStatus.JAMMED | SANEStatus.NO_DOCS | SANEStatus.COVER_OPEN | SANEStatus.IO_ERROR | SANEStatus.NO_MEM | SANEStatus.ACCESS_DENIED;
|
|
57
57
|
parameters: null;
|
|
58
58
|
promise: Promise<void>;
|
|
@@ -60,7 +60,7 @@ export declare class ScanDataReader<T extends ScanDataReaderEventMap = ScanDataR
|
|
|
60
60
|
status: SANEStatus.GOOD;
|
|
61
61
|
parameters: SANEParameters;
|
|
62
62
|
promise: Promise<void>;
|
|
63
|
-
}
|
|
63
|
+
}>;
|
|
64
64
|
/**
|
|
65
65
|
* Cancel scanning operation.
|
|
66
66
|
*/
|
package/dist/readers.js
CHANGED
|
@@ -136,48 +136,46 @@ class ScanDataReader extends EventBaseClass {
|
|
|
136
136
|
* Start scanning operation.
|
|
137
137
|
*/
|
|
138
138
|
start() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
if (this._used) {
|
|
141
|
+
// readers are single use
|
|
142
|
+
throw new Error("Scan readers cannot be reused.");
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
const { status } = yield this._lib.sane_start();
|
|
146
|
+
if (status !== _1.SANEStatus.GOOD) {
|
|
147
|
+
return {
|
|
148
|
+
status,
|
|
149
|
+
parameters: null,
|
|
150
|
+
promise: Promise.reject(new Error(`Status ${_1.SANEStatus[status]} during sane_start().`)),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
this._used = true;
|
|
154
|
+
}
|
|
155
|
+
// after successful start, sane_cancel needs to be called and we need
|
|
156
|
+
// to wait for sane_read, so subsequent fails need to use this._killed
|
|
157
|
+
// and run the read loop
|
|
158
|
+
const { status, parameters } = yield this._lib.sane_get_parameters();
|
|
149
159
|
if (status !== _1.SANEStatus.GOOD) {
|
|
160
|
+
this._killed = new Error(`Status ${_1.SANEStatus[status]} during sane_get_parameters().`);
|
|
150
161
|
return {
|
|
151
|
-
status,
|
|
152
|
-
|
|
153
|
-
promise: Promise.reject(new Error(`Status ${_1.SANEStatus[status]} during sane_start().`)),
|
|
162
|
+
status, parameters,
|
|
163
|
+
promise: this._readPromise(parameters),
|
|
154
164
|
};
|
|
155
165
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (status !== _1.SANEStatus.GOOD) {
|
|
163
|
-
this._killed = new Error(`Status ${_1.SANEStatus[status]} during sane_get_parameters().`);
|
|
166
|
+
try {
|
|
167
|
+
this.fire('start', parameters);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
this._killed = e instanceof Error ? e : new Error("Unknown error while starting the scan.");
|
|
171
|
+
}
|
|
164
172
|
return {
|
|
165
173
|
status, parameters,
|
|
166
|
-
promise: this._readPromise(parameters)
|
|
174
|
+
promise: this._readPromise(parameters).finally(() => {
|
|
175
|
+
this.fire('stop', parameters, this._killed instanceof Error ? this._killed : null);
|
|
176
|
+
}),
|
|
167
177
|
};
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
this.fire('start', parameters);
|
|
171
|
-
}
|
|
172
|
-
catch (e) {
|
|
173
|
-
this._killed = e instanceof Error ? e : new Error("Unknown error while starting the scan.");
|
|
174
|
-
}
|
|
175
|
-
return {
|
|
176
|
-
status, parameters,
|
|
177
|
-
promise: this._readPromise(parameters).finally(() => {
|
|
178
|
-
this.fire('stop', parameters, this._killed instanceof Error ? this._killed : null);
|
|
179
|
-
}),
|
|
180
|
-
};
|
|
178
|
+
});
|
|
181
179
|
}
|
|
182
180
|
/**
|
|
183
181
|
* Cancel scanning operation.
|