sane-wasm 0.2.0 → 0.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 +7 -7
- package/build/libsane.wasm +0 -0
- package/dist/index.d.ts +337 -35
- package/dist/index.js +20 -0
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -24,9 +24,9 @@ https://www.npmjs.com/package/sane-wasm?activeTab=code
|
|
|
24
24
|
npm install -D sane-wasm
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
The main .js will not be bundled with your application. A loader ([lib/loader.js](lib/loader.js)) is provided to automatically load the .js/.wasm files from a CDN ([jsdelivr.com](https://www.jsdelivr.com/)). You can configure the loader to serve the files from your server if you want.
|
|
27
|
+
The main .js will not be bundled with your application. A loader ([lib/loader.js](https://github.com/goncalomb/sane-wasm/blob/master/lib/loader.js)) is provided to automatically load the .js/.wasm files from a CDN ([jsdelivr.com](https://www.jsdelivr.com/)). You can configure the loader to serve the files from your server if you want.
|
|
28
28
|
|
|
29
|
-
See [examples/webpack/](examples/webpack
|
|
29
|
+
See [examples/webpack/](https://github.com/goncalomb/sane-wasm/tree/master/examples/webpack) for a working example.
|
|
30
30
|
|
|
31
31
|
### For Node.js
|
|
32
32
|
|
|
@@ -36,7 +36,7 @@ npm install sane-wasm usb
|
|
|
36
36
|
|
|
37
37
|
The usb package ([node-usb](https://github.com/node-usb/node-usb)) is required to provide USB functionality.
|
|
38
38
|
|
|
39
|
-
See [examples/node/](examples/node
|
|
39
|
+
See [examples/node/](https://github.com/goncalomb/sane-wasm/tree/master/examples/node) for a working example.
|
|
40
40
|
|
|
41
41
|
### As Git Submodule (not recommended) / Custom Build
|
|
42
42
|
|
|
@@ -103,7 +103,7 @@ usage: build.sh [options]
|
|
|
103
103
|
|
|
104
104
|
To do a full build use `npm run build`.
|
|
105
105
|
|
|
106
|
-
##
|
|
106
|
+
## API
|
|
107
107
|
|
|
108
108
|
Most of the SANE API is exposed as-is. Check the [SANE Standard](https://sane-project.gitlab.io/standard/index.html).
|
|
109
109
|
|
|
@@ -113,12 +113,12 @@ Some safeguards are in place to avoid API misuse and prevent memory leaks. It's
|
|
|
113
113
|
|
|
114
114
|
The most important difference with the underlying SANE API is that **device handles are not exposed**. This means that `sane_open()` does not return a device handle. A single handle is managed by the internal code. This effectively means that **only one device can be accessed at a time**. This was a design decision made to simplify the API and prevent other issues.
|
|
115
115
|
|
|
116
|
-
> Personally, I believe that this is an acceptable change, especially for WebAssembly where it may be easier to lose track of opened resources and crash the application. The SANE API is also somewhat unforgiving and building more safeguards around it (especially with multiple handles) is not worth the effort. Ultimately I don't see a use that requires more than one device open at a time.
|
|
116
|
+
> Personally, I believe that this is an acceptable change, especially for WebAssembly where it may be easier to lose track of opened resources and crash the application. The SANE API is also somewhat unforgiving and building more safeguards around it (especially with multiple handles) is not worth the effort. Ultimately I don't see a use that requires more than one device open at a time. -goncalomb
|
|
117
117
|
|
|
118
118
|
### Documentation
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
Check API documentation at: [goncalomb.github.io/sane-wasm/modules.html](https://goncalomb.github.io/sane-wasm/modules.html).
|
|
121
121
|
|
|
122
122
|
## License
|
|
123
123
|
|
|
124
|
-
Because of the weird state of SANE's licensing (GPL + linking exception, on some backends), see [backends/LICENSE](https://gitlab.com/sane-project/backends/-/blob/master/LICENSE). I'm releasing this project with dual licensing [GNU GPLv2](LICENSE.txt) + [GNU LGPLv2.1](LICENSE-LGPL.txt). IANAL, you choose.
|
|
124
|
+
Because of the weird state of SANE's licensing (GPL + linking exception, on some backends), see [backends/LICENSE](https://gitlab.com/sane-project/backends/-/blob/master/LICENSE). I'm releasing this project with dual licensing [GNU GPLv2](https://github.com/goncalomb/sane-wasm/blob/master/LICENSE.txt) + [GNU LGPLv2.1](https://github.com/goncalomb/sane-wasm/blob/master/LICENSE-LGPL.txt). IANAL, you choose.
|
package/build/libsane.wasm
CHANGED
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Equivalent to the SANE API C enum `SANE_Status`.
|
|
3
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#status-type}
|
|
4
|
+
*/
|
|
1
5
|
export declare enum SANEStatus {
|
|
2
6
|
GOOD = 0,
|
|
3
7
|
UNSUPPORTED = 1,
|
|
@@ -12,6 +16,10 @@ export declare enum SANEStatus {
|
|
|
12
16
|
NO_MEM = 10,
|
|
13
17
|
ACCESS_DENIED = 11
|
|
14
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Equivalent to the SANE API C enum `SANE_Value_Type`.
|
|
21
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-value-type}
|
|
22
|
+
*/
|
|
15
23
|
export declare enum SANEValueType {
|
|
16
24
|
BOOL = 0,
|
|
17
25
|
INT = 1,
|
|
@@ -20,6 +28,10 @@ export declare enum SANEValueType {
|
|
|
20
28
|
BUTTON = 4,
|
|
21
29
|
GROUP = 5
|
|
22
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Equivalent to the SANE API C enum `SANE_Unit`.
|
|
33
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-value-unit}
|
|
34
|
+
*/
|
|
23
35
|
export declare enum SANEUnit {
|
|
24
36
|
NONE = 0,
|
|
25
37
|
PIXEL = 1,
|
|
@@ -29,12 +41,20 @@ export declare enum SANEUnit {
|
|
|
29
41
|
PERCENT = 5,
|
|
30
42
|
MICROSECOND = 6
|
|
31
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Equivalent to the SANE API C enum `SANE_Constraint_Type`.
|
|
46
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-value-constraints}
|
|
47
|
+
*/
|
|
32
48
|
export declare enum SANEConstraintType {
|
|
33
49
|
NONE = 0,
|
|
34
50
|
RANGE = 1,
|
|
35
51
|
WORD_LIST = 2,
|
|
36
52
|
STRING_LIST = 3
|
|
37
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Equivalent to the SANE API C enum `SANE_Frame`.
|
|
56
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-get-parameters}
|
|
57
|
+
*/
|
|
38
58
|
export declare enum SANEFrame {
|
|
39
59
|
GRAY = 0,
|
|
40
60
|
RGB = 1,
|
|
@@ -42,22 +62,69 @@ export declare enum SANEFrame {
|
|
|
42
62
|
GREEN = 3,
|
|
43
63
|
BLUE = 4
|
|
44
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Library state. This is provided by sane-wasm, it's not part of SANE API.
|
|
67
|
+
*/
|
|
45
68
|
export type SANEState = {
|
|
69
|
+
/**
|
|
70
|
+
* Is the library initialized with {@link LibSANE.sane_init}?
|
|
71
|
+
*/
|
|
46
72
|
initialized: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Version code provided by the last {@link LibSANE.sane_init} call.
|
|
75
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#version-control}
|
|
76
|
+
*/
|
|
47
77
|
version_code: number;
|
|
78
|
+
/**
|
|
79
|
+
* Version code (decoded) provided by the last {@link LibSANE.sane_init} call.
|
|
80
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#version-control}
|
|
81
|
+
*/
|
|
48
82
|
version: {
|
|
49
83
|
major: number;
|
|
50
84
|
minor: number;
|
|
51
85
|
build: number;
|
|
52
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Is a device open with {@link LibSANE.sane_open}?
|
|
89
|
+
*/
|
|
53
90
|
open: boolean;
|
|
54
91
|
};
|
|
92
|
+
/**
|
|
93
|
+
* Equivalent to the SANE API C type `SANE_Device`.
|
|
94
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#device-descriptor-type}
|
|
95
|
+
*/
|
|
55
96
|
export type SANEDevice = {
|
|
56
97
|
name: string;
|
|
57
98
|
vendor: string;
|
|
58
99
|
model: string;
|
|
59
100
|
type: string;
|
|
60
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Equivalent to the SANE API C bit mask `SANE_CAP_*`.
|
|
104
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-capabilities}
|
|
105
|
+
*/
|
|
106
|
+
export type SANECap = {
|
|
107
|
+
SOFT_SELECT: boolean;
|
|
108
|
+
HARD_SELECT: boolean;
|
|
109
|
+
SOFT_DETECT: boolean;
|
|
110
|
+
EMULATED: boolean;
|
|
111
|
+
AUTOMATIC: boolean;
|
|
112
|
+
INACTIVE: boolean;
|
|
113
|
+
ADVANCED: boolean;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Equivalent to the SANE API C type `SANE_Range`.
|
|
117
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-descriptor-type}
|
|
118
|
+
*/
|
|
119
|
+
export type SANERange = {
|
|
120
|
+
min: number;
|
|
121
|
+
max: number;
|
|
122
|
+
quant: number;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Equivalent to the SANE API C type `SANE_Option_Descriptor`.
|
|
126
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-descriptor-type}
|
|
127
|
+
*/
|
|
61
128
|
export type SANEOptionDescriptor = {
|
|
62
129
|
name: string;
|
|
63
130
|
title: string;
|
|
@@ -65,25 +132,13 @@ export type SANEOptionDescriptor = {
|
|
|
65
132
|
type: SANEValueType;
|
|
66
133
|
unit: SANEUnit;
|
|
67
134
|
size: number;
|
|
68
|
-
cap:
|
|
69
|
-
SOFT_SELECT: boolean;
|
|
70
|
-
HARD_SELECT: boolean;
|
|
71
|
-
SOFT_DETECT: boolean;
|
|
72
|
-
EMULATED: boolean;
|
|
73
|
-
AUTOMATIC: boolean;
|
|
74
|
-
INACTIVE: boolean;
|
|
75
|
-
ADVANCED: boolean;
|
|
76
|
-
};
|
|
135
|
+
cap: SANECap;
|
|
77
136
|
} & ({
|
|
78
137
|
constraint_type: SANEConstraintType.NONE;
|
|
79
138
|
constraint: null;
|
|
80
139
|
} | {
|
|
81
140
|
constraint_type: SANEConstraintType.RANGE;
|
|
82
|
-
constraint:
|
|
83
|
-
min: number;
|
|
84
|
-
max: number;
|
|
85
|
-
quant: number;
|
|
86
|
-
};
|
|
141
|
+
constraint: SANERange;
|
|
87
142
|
} | {
|
|
88
143
|
constraint_type: SANEConstraintType.WORD_LIST;
|
|
89
144
|
constraint: number[];
|
|
@@ -91,11 +146,19 @@ export type SANEOptionDescriptor = {
|
|
|
91
146
|
constraint_type: SANEConstraintType.STRING_LIST;
|
|
92
147
|
constraint: string[];
|
|
93
148
|
});
|
|
149
|
+
/**
|
|
150
|
+
* Equivalent to the SANE API C bit mask `SANE_INFO_*`.
|
|
151
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-control-option}
|
|
152
|
+
*/
|
|
94
153
|
export type SANEInfo = {
|
|
95
154
|
INEXACT: boolean;
|
|
96
155
|
RELOAD_OPTIONS: boolean;
|
|
97
156
|
RELOAD_PARAMS: boolean;
|
|
98
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* Equivalent to the SANE API C type `SANE_Parameters`.
|
|
160
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-get-parameters}
|
|
161
|
+
*/
|
|
99
162
|
export type SANEParameters = {
|
|
100
163
|
format: SANEFrame;
|
|
101
164
|
last_frame: boolean;
|
|
@@ -104,86 +167,325 @@ export type SANEParameters = {
|
|
|
104
167
|
lines: number;
|
|
105
168
|
depth: number;
|
|
106
169
|
};
|
|
107
|
-
|
|
170
|
+
/**
|
|
171
|
+
* @private Type for enums provided by the core SANE Emscripten module.
|
|
172
|
+
* @deprecated
|
|
173
|
+
*/
|
|
174
|
+
export type SANEEnum<E, TE> = E & {
|
|
108
175
|
/**
|
|
109
176
|
* @deprecated Use reverse map already built into TS enums.
|
|
110
177
|
*/
|
|
111
178
|
asString: (value: TE) => string;
|
|
112
179
|
};
|
|
180
|
+
/**
|
|
181
|
+
* The core SANE Emscripten module.
|
|
182
|
+
*/
|
|
113
183
|
export interface LibSANE {
|
|
184
|
+
/**
|
|
185
|
+
* Commit hash of sane-wasm.
|
|
186
|
+
*/
|
|
114
187
|
SANE_WASM_COMMIT: string;
|
|
188
|
+
/**
|
|
189
|
+
* Version code of sane-wasm.
|
|
190
|
+
*/
|
|
115
191
|
SANE_WASM_VERSION: string;
|
|
192
|
+
/**
|
|
193
|
+
* List of SANE API backends built into sane-wasm.
|
|
194
|
+
*/
|
|
116
195
|
SANE_WASM_BACKENDS: string;
|
|
196
|
+
/**
|
|
197
|
+
* SANE API version code (major).
|
|
198
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#version-control}
|
|
199
|
+
*/
|
|
117
200
|
SANE_CURRENT_MAJOR: number;
|
|
201
|
+
/**
|
|
202
|
+
* SANE API version code (minor).
|
|
203
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#version-control}
|
|
204
|
+
*/
|
|
118
205
|
SANE_CURRENT_MINOR: number;
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated Consider using the SANEStatus enum directly.
|
|
208
|
+
*
|
|
209
|
+
* This object is not going away anytime soon (or ever probably).
|
|
210
|
+
*
|
|
211
|
+
* But you should consider using the equivalent enum because it doesn't
|
|
212
|
+
* require having a reference to the library module. All enums are
|
|
213
|
+
* exported with the package.
|
|
214
|
+
*/
|
|
119
215
|
SANE_STATUS: SANEEnum<typeof SANEStatus, SANEStatus>;
|
|
216
|
+
/**
|
|
217
|
+
* @deprecated Consider using the SANEValueType enum directly.
|
|
218
|
+
*
|
|
219
|
+
* This object is not going away anytime soon (or ever probably).
|
|
220
|
+
*
|
|
221
|
+
* But you should consider using the equivalent enum because it doesn't
|
|
222
|
+
* require having a reference to the library module. All enums are
|
|
223
|
+
* exported with the package.
|
|
224
|
+
*/
|
|
120
225
|
SANE_TYPE: SANEEnum<typeof SANEValueType, SANEValueType>;
|
|
226
|
+
/**
|
|
227
|
+
* @deprecated Consider using the SANEUnit enum directly.
|
|
228
|
+
*
|
|
229
|
+
* This object is not going away anytime soon (or ever probably).
|
|
230
|
+
*
|
|
231
|
+
* But you should consider using the equivalent enum because it doesn't
|
|
232
|
+
* require having a reference to the library module. All enums are
|
|
233
|
+
* exported with the package.
|
|
234
|
+
*/
|
|
121
235
|
SANE_UNIT: SANEEnum<typeof SANEUnit, SANEUnit>;
|
|
236
|
+
/**
|
|
237
|
+
* @deprecated Consider using the SANEConstraintType enum directly.
|
|
238
|
+
*
|
|
239
|
+
* This object is not going away anytime soon (or ever probably).
|
|
240
|
+
*
|
|
241
|
+
* But you should consider using the equivalent enum because it doesn't
|
|
242
|
+
* require having a reference to the library module. All enums are
|
|
243
|
+
* exported with the package.
|
|
244
|
+
*/
|
|
122
245
|
SANE_CONSTRAINT: SANEEnum<typeof SANEConstraintType, SANEConstraintType>;
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Consider using the SANEFrame enum directly.
|
|
248
|
+
*
|
|
249
|
+
* This object is not going away anytime soon (or ever probably).
|
|
250
|
+
*
|
|
251
|
+
* But you should consider using the equivalent enum because it doesn't
|
|
252
|
+
* require having a reference to the library module. All enums are
|
|
253
|
+
* exported with the package.
|
|
254
|
+
*/
|
|
123
255
|
SANE_FRAME: SANEEnum<typeof SANEFrame, SANEFrame>;
|
|
256
|
+
/**
|
|
257
|
+
* Get the current state of the library.
|
|
258
|
+
*
|
|
259
|
+
* This is provided by sane-wasm, it's not part of SANE API.
|
|
260
|
+
*/
|
|
124
261
|
sane_get_state: () => SANEState;
|
|
262
|
+
/**
|
|
263
|
+
* Equivalent to the SANE API C function `sane_init`.
|
|
264
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-init}
|
|
265
|
+
*/
|
|
125
266
|
sane_init: () => {
|
|
126
|
-
status: SANEStatus;
|
|
267
|
+
status: SANEStatus.GOOD;
|
|
127
268
|
version_code: number;
|
|
269
|
+
} | {
|
|
270
|
+
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
271
|
+
version_code: null;
|
|
128
272
|
};
|
|
273
|
+
/**
|
|
274
|
+
* Equivalent to the SANE API C function `sane_exit`.
|
|
275
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-exit}
|
|
276
|
+
*/
|
|
129
277
|
sane_exit: () => Promise<{
|
|
130
278
|
status: SANEStatus;
|
|
131
279
|
}>;
|
|
280
|
+
/**
|
|
281
|
+
* Equivalent to the SANE API C function `sane_get_devices`.
|
|
282
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-get-devices}
|
|
283
|
+
*/
|
|
132
284
|
sane_get_devices: () => Promise<{
|
|
133
|
-
status: SANEStatus;
|
|
285
|
+
status: SANEStatus.GOOD;
|
|
134
286
|
devices: SANEDevice[];
|
|
287
|
+
} | {
|
|
288
|
+
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
289
|
+
devices: null;
|
|
135
290
|
}>;
|
|
291
|
+
/**
|
|
292
|
+
* Equivalent to the SANE API C function `sane_open`.
|
|
293
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-open}
|
|
294
|
+
*/
|
|
136
295
|
sane_open: (devicename: string) => Promise<{
|
|
137
296
|
status: SANEStatus;
|
|
138
297
|
}>;
|
|
298
|
+
/**
|
|
299
|
+
* Equivalent to the SANE API C function `sane_close`.
|
|
300
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-close}
|
|
301
|
+
*/
|
|
139
302
|
sane_close: () => Promise<{
|
|
140
303
|
status: SANEStatus;
|
|
141
304
|
}>;
|
|
305
|
+
/**
|
|
306
|
+
* Equivalent to the SANE API C function `sane_get_option_descriptor`.
|
|
307
|
+
*
|
|
308
|
+
* The result `option_descriptor` can be null even with
|
|
309
|
+
* `status = SANEStatus.GOOD`, it signals invalid option index.
|
|
310
|
+
*
|
|
311
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-get-option-descriptor}
|
|
312
|
+
*/
|
|
142
313
|
sane_get_option_descriptor: (option: number) => {
|
|
143
314
|
status: SANEStatus;
|
|
144
315
|
option_descriptor: SANEOptionDescriptor | null;
|
|
145
316
|
};
|
|
317
|
+
/**
|
|
318
|
+
* Equivalent to the SANE API C function `sane_control_option`.
|
|
319
|
+
*
|
|
320
|
+
* With `a = SANE_ACTION_GET_VALUE` (get option value).
|
|
321
|
+
*
|
|
322
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-control-option}
|
|
323
|
+
*/
|
|
146
324
|
sane_control_option_get_value: (option: number) => Promise<{
|
|
147
|
-
status: SANEStatus;
|
|
325
|
+
status: SANEStatus.GOOD;
|
|
148
326
|
value: any;
|
|
327
|
+
} | {
|
|
328
|
+
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
329
|
+
value: null;
|
|
149
330
|
}>;
|
|
331
|
+
/**
|
|
332
|
+
* Equivalent to the SANE API C function `sane_control_option`.
|
|
333
|
+
*
|
|
334
|
+
* With `a = SANE_ACTION_SET_VALUE` (set option value).
|
|
335
|
+
*
|
|
336
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-control-option}
|
|
337
|
+
*/
|
|
150
338
|
sane_control_option_set_value: (option: number, value: any) => Promise<{
|
|
151
|
-
status: SANEStatus;
|
|
339
|
+
status: SANEStatus.GOOD;
|
|
152
340
|
info: SANEInfo;
|
|
341
|
+
} | {
|
|
342
|
+
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
343
|
+
info: null;
|
|
153
344
|
}>;
|
|
345
|
+
/**
|
|
346
|
+
* Equivalent to the SANE API C function `sane_control_option`.
|
|
347
|
+
*
|
|
348
|
+
* With `a = SANE_ACTION_SET_AUTO` (set option automatic).
|
|
349
|
+
*
|
|
350
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-control-option}
|
|
351
|
+
*/
|
|
154
352
|
sane_control_option_set_auto: (option: number) => Promise<{
|
|
155
|
-
status: SANEStatus;
|
|
353
|
+
status: SANEStatus.GOOD;
|
|
156
354
|
info: SANEInfo;
|
|
355
|
+
} | {
|
|
356
|
+
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
357
|
+
info: null;
|
|
157
358
|
}>;
|
|
359
|
+
/**
|
|
360
|
+
* Equivalent to the SANE API C function `sane_get_parameters`.
|
|
361
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-get-parameters}
|
|
362
|
+
*/
|
|
158
363
|
sane_get_parameters: () => {
|
|
159
|
-
status: SANEStatus;
|
|
364
|
+
status: SANEStatus.GOOD;
|
|
160
365
|
parameters: SANEParameters;
|
|
366
|
+
} | {
|
|
367
|
+
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
368
|
+
parameters: null;
|
|
161
369
|
};
|
|
370
|
+
/**
|
|
371
|
+
* Equivalent to the SANE API C function `sane_start`.
|
|
372
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-start}
|
|
373
|
+
*/
|
|
162
374
|
sane_start: () => {
|
|
163
375
|
status: SANEStatus;
|
|
164
376
|
};
|
|
377
|
+
/**
|
|
378
|
+
* Equivalent to the SANE API C function `sane_read`.
|
|
379
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-read}
|
|
380
|
+
*/
|
|
165
381
|
sane_read: () => Promise<{
|
|
166
|
-
status: SANEStatus;
|
|
382
|
+
status: SANEStatus.GOOD;
|
|
167
383
|
data: Uint8Array;
|
|
384
|
+
} | {
|
|
385
|
+
status: Exclude<SANEStatus, SANEStatus.GOOD>;
|
|
386
|
+
data: null;
|
|
168
387
|
}>;
|
|
388
|
+
/**
|
|
389
|
+
* Equivalent to the SANE API C function `sane_cancel`.
|
|
390
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-cancel}
|
|
391
|
+
*/
|
|
169
392
|
sane_cancel: () => Promise<{
|
|
170
393
|
status: SANEStatus;
|
|
171
394
|
}>;
|
|
395
|
+
/**
|
|
396
|
+
* Equivalent to the SANE API C function `sane_strstatus`.
|
|
397
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-strstatus}
|
|
398
|
+
*/
|
|
172
399
|
sane_strstatus: (status: SANEStatus) => string;
|
|
173
400
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
401
|
+
/**
|
|
402
|
+
* SANE Emscripten module options (specific to sane-wasm).
|
|
403
|
+
*/
|
|
404
|
+
export type LibSANEOptions = {
|
|
405
|
+
/**
|
|
406
|
+
* Loader URL that serves the build artifacts (libsane.js etc.).
|
|
407
|
+
*
|
|
408
|
+
* The loader is only used on web environments.
|
|
409
|
+
*
|
|
410
|
+
* @defaultvalue "sane-wasm @ jsdelivr.net"
|
|
411
|
+
*/
|
|
412
|
+
loaderURL?: string;
|
|
413
|
+
/**
|
|
414
|
+
* Should the loader prefetch the resources to a Bob object? This is
|
|
415
|
+
* required when loading from a different origin. Check the loader
|
|
416
|
+
* code for more information.
|
|
417
|
+
*
|
|
418
|
+
* The loader is only used on web environments.
|
|
419
|
+
*
|
|
420
|
+
* @defaultvalue `true`
|
|
421
|
+
*/
|
|
422
|
+
loaderPrefetchToBlob?: boolean;
|
|
423
|
+
/**
|
|
424
|
+
* Should the loader remove the global module variable `window.LibSANE`?
|
|
425
|
+
*
|
|
426
|
+
* The loader is only used on web environments.
|
|
427
|
+
*
|
|
428
|
+
* @defaultvalue `true`
|
|
429
|
+
*/
|
|
430
|
+
loaderRemoveGlobal?: boolean;
|
|
431
|
+
/**
|
|
432
|
+
* Enables SANE low-level debug messages, this can be quite verbose.
|
|
433
|
+
*
|
|
434
|
+
* @defaultvalue `false`
|
|
435
|
+
*/
|
|
436
|
+
debugSANE?: boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Enables libusb low-level debug messages, this can be quite verbose.
|
|
439
|
+
*
|
|
440
|
+
* @defaultvalue `false`
|
|
441
|
+
*/
|
|
442
|
+
debugUSB?: boolean;
|
|
443
|
+
/**
|
|
444
|
+
* Enables debug messages for SANE function calls.
|
|
445
|
+
*
|
|
446
|
+
* @defaultvalue `false`
|
|
447
|
+
*/
|
|
448
|
+
debugFunctionCalls?: boolean;
|
|
449
|
+
/**
|
|
450
|
+
* Sets the number of test devices for SANE's test backend.
|
|
451
|
+
*
|
|
452
|
+
* @defaultvalue `0`
|
|
453
|
+
*/
|
|
454
|
+
debugTestDevices?: number;
|
|
455
|
+
/**
|
|
456
|
+
* Enables sane-wasm "promisify" to normalize the API. See pre.js for more
|
|
457
|
+
* information.
|
|
458
|
+
*
|
|
459
|
+
* @deprecated Setting this to `false` changes the API definition! Some
|
|
460
|
+
* functions may stop being asynchronous in some cases. You want this
|
|
461
|
+
* option enabled! This option may be removed in the future.
|
|
462
|
+
*
|
|
463
|
+
* @defaultvalue `true`
|
|
464
|
+
*/
|
|
465
|
+
promisify?: boolean;
|
|
466
|
+
/**
|
|
467
|
+
* Enables sane-wasm "promisify" queue that queues function calls to
|
|
468
|
+
* prevent issues with calling multiple asynchronous functions. See pre.js
|
|
469
|
+
* for more information.
|
|
470
|
+
*
|
|
471
|
+
* @deprecated You want this option enabled! This option may be removed in
|
|
472
|
+
* the future.
|
|
473
|
+
*
|
|
474
|
+
* @defaultvalue `true`
|
|
475
|
+
*/
|
|
476
|
+
promisifyQueue?: boolean;
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* The factory that initializes the core SANE Emscripten module.
|
|
480
|
+
*/
|
|
481
|
+
export type LibSANEFactory = (options?: {
|
|
482
|
+
/**
|
|
483
|
+
* Emscripten module options specific to sane-wasm.
|
|
484
|
+
*/
|
|
485
|
+
sane?: LibSANEOptions;
|
|
486
|
+
/**
|
|
487
|
+
* Other Emscripten module options.
|
|
488
|
+
*/
|
|
187
489
|
[k: string]: any;
|
|
188
490
|
}) => Promise<LibSANE>;
|
|
189
491
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.libsane = exports.SANEFrame = exports.SANEConstraintType = exports.SANEUnit = exports.SANEValueType = exports.SANEStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Equivalent to the SANE API C enum `SANE_Status`.
|
|
6
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#status-type}
|
|
7
|
+
*/
|
|
4
8
|
var SANEStatus;
|
|
5
9
|
(function (SANEStatus) {
|
|
6
10
|
SANEStatus[SANEStatus["GOOD"] = 0] = "GOOD";
|
|
@@ -16,6 +20,10 @@ var SANEStatus;
|
|
|
16
20
|
SANEStatus[SANEStatus["NO_MEM"] = 10] = "NO_MEM";
|
|
17
21
|
SANEStatus[SANEStatus["ACCESS_DENIED"] = 11] = "ACCESS_DENIED";
|
|
18
22
|
})(SANEStatus || (exports.SANEStatus = SANEStatus = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Equivalent to the SANE API C enum `SANE_Value_Type`.
|
|
25
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-value-type}
|
|
26
|
+
*/
|
|
19
27
|
var SANEValueType;
|
|
20
28
|
(function (SANEValueType) {
|
|
21
29
|
SANEValueType[SANEValueType["BOOL"] = 0] = "BOOL";
|
|
@@ -25,6 +33,10 @@ var SANEValueType;
|
|
|
25
33
|
SANEValueType[SANEValueType["BUTTON"] = 4] = "BUTTON";
|
|
26
34
|
SANEValueType[SANEValueType["GROUP"] = 5] = "GROUP";
|
|
27
35
|
})(SANEValueType || (exports.SANEValueType = SANEValueType = {}));
|
|
36
|
+
/**
|
|
37
|
+
* Equivalent to the SANE API C enum `SANE_Unit`.
|
|
38
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-value-unit}
|
|
39
|
+
*/
|
|
28
40
|
var SANEUnit;
|
|
29
41
|
(function (SANEUnit) {
|
|
30
42
|
SANEUnit[SANEUnit["NONE"] = 0] = "NONE";
|
|
@@ -35,6 +47,10 @@ var SANEUnit;
|
|
|
35
47
|
SANEUnit[SANEUnit["PERCENT"] = 5] = "PERCENT";
|
|
36
48
|
SANEUnit[SANEUnit["MICROSECOND"] = 6] = "MICROSECOND";
|
|
37
49
|
})(SANEUnit || (exports.SANEUnit = SANEUnit = {}));
|
|
50
|
+
/**
|
|
51
|
+
* Equivalent to the SANE API C enum `SANE_Constraint_Type`.
|
|
52
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#option-value-constraints}
|
|
53
|
+
*/
|
|
38
54
|
var SANEConstraintType;
|
|
39
55
|
(function (SANEConstraintType) {
|
|
40
56
|
SANEConstraintType[SANEConstraintType["NONE"] = 0] = "NONE";
|
|
@@ -42,6 +58,10 @@ var SANEConstraintType;
|
|
|
42
58
|
SANEConstraintType[SANEConstraintType["WORD_LIST"] = 2] = "WORD_LIST";
|
|
43
59
|
SANEConstraintType[SANEConstraintType["STRING_LIST"] = 3] = "STRING_LIST";
|
|
44
60
|
})(SANEConstraintType || (exports.SANEConstraintType = SANEConstraintType = {}));
|
|
61
|
+
/**
|
|
62
|
+
* Equivalent to the SANE API C enum `SANE_Frame`.
|
|
63
|
+
* @see {@link https://sane-project.gitlab.io/standard/1.06/api.html#sane-get-parameters}
|
|
64
|
+
*/
|
|
45
65
|
var SANEFrame;
|
|
46
66
|
(function (SANEFrame) {
|
|
47
67
|
SANEFrame[SANEFrame["GRAY"] = 0] = "GRAY";
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sane-wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A project to bring the SANE API to the web.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "jest",
|
|
9
|
-
"clean": "npm run clean:
|
|
10
|
-
"clean:
|
|
9
|
+
"clean": "npm run clean:ts && npm run clean:sane",
|
|
10
|
+
"clean:ts": "rm -rf dist/ docs/",
|
|
11
11
|
"clean:sane": "./build.sh --no-build --clean",
|
|
12
|
-
"prebuild": "rm -rf dist/ build/",
|
|
13
|
-
"build": "npm run build:
|
|
14
|
-
"build:
|
|
12
|
+
"prebuild": "rm -rf dist/ docs/ build/",
|
|
13
|
+
"build": "npm run build:ts && npm run build:sane",
|
|
14
|
+
"build:ts": "tsc && typedoc",
|
|
15
|
+
"postbuild:ts": "rm -rf dist/docs-plugin.*",
|
|
15
16
|
"build:sane": "./build.sh --with-docker --clean",
|
|
16
17
|
"debug:sane": "./build.sh --with-docker --debug --emrun"
|
|
17
18
|
},
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"jest": "^29.6.4",
|
|
51
52
|
"jest-extended": "^4.0.1",
|
|
53
|
+
"typedoc": "^0.25.0",
|
|
52
54
|
"typescript": "^5.2.2"
|
|
53
55
|
}
|
|
54
56
|
}
|