Skip to content

Commit 290afd8

Browse files
committed
feat: add option for ECL/Version in Wasm
1 parent f161032 commit 290afd8

7 files changed

+454
-26
lines changed

pkg/fast_qr.d.ts

+203-7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,192 @@ export enum ImageBackgroundShape {
6060
RoundedSquare = 2,
6161
}
6262
/**
63+
* Error Correction Coding has 4 levels
64+
*/
65+
export enum ECL {
66+
/**
67+
* Low, 7%
68+
*/
69+
L = 0,
70+
/**
71+
* Medium, 15%
72+
*/
73+
M = 1,
74+
/**
75+
* Quartile, 25%
76+
*/
77+
Q = 2,
78+
/**
79+
* High, 30%
80+
*/
81+
H = 3,
82+
}
83+
/**
84+
* Enum containing all possible `QRCode` versions
85+
*/
86+
export enum Version {
87+
/**
88+
* Version n°01
89+
*/
90+
V01 = 0,
91+
/**
92+
* Version n°02
93+
*/
94+
V02 = 1,
95+
/**
96+
* Version n°03
97+
*/
98+
V03 = 2,
99+
/**
100+
* Version n°04
101+
*/
102+
V04 = 3,
103+
/**
104+
* Version n°05
105+
*/
106+
V05 = 4,
107+
/**
108+
* Version n°06
109+
*/
110+
V06 = 5,
111+
/**
112+
* Version n°07
113+
*/
114+
V07 = 6,
115+
/**
116+
* Version n°08
117+
*/
118+
V08 = 7,
119+
/**
120+
* Version n°09
121+
*/
122+
V09 = 8,
123+
/**
124+
* Version n°10
125+
*/
126+
V10 = 9,
127+
/**
128+
* Version n°11
129+
*/
130+
V11 = 10,
131+
/**
132+
* Version n°12
133+
*/
134+
V12 = 11,
135+
/**
136+
* Version n°13
137+
*/
138+
V13 = 12,
139+
/**
140+
* Version n°14
141+
*/
142+
V14 = 13,
143+
/**
144+
* Version n°15
145+
*/
146+
V15 = 14,
147+
/**
148+
* Version n°16
149+
*/
150+
V16 = 15,
151+
/**
152+
* Version n°17
153+
*/
154+
V17 = 16,
155+
/**
156+
* Version n°18
157+
*/
158+
V18 = 17,
159+
/**
160+
* Version n°19
161+
*/
162+
V19 = 18,
163+
/**
164+
* Version n°20
165+
*/
166+
V20 = 19,
167+
/**
168+
* Version n°21
169+
*/
170+
V21 = 20,
171+
/**
172+
* Version n°22
173+
*/
174+
V22 = 21,
175+
/**
176+
* Version n°23
177+
*/
178+
V23 = 22,
179+
/**
180+
* Version n°24
181+
*/
182+
V24 = 23,
183+
/**
184+
* Version n°25
185+
*/
186+
V25 = 24,
187+
/**
188+
* Version n°26
189+
*/
190+
V26 = 25,
191+
/**
192+
* Version n°27
193+
*/
194+
V27 = 26,
195+
/**
196+
* Version n°28
197+
*/
198+
V28 = 27,
199+
/**
200+
* Version n°29
201+
*/
202+
V29 = 28,
203+
/**
204+
* Version n°30
205+
*/
206+
V30 = 29,
207+
/**
208+
* Version n°31
209+
*/
210+
V31 = 30,
211+
/**
212+
* Version n°32
213+
*/
214+
V32 = 31,
215+
/**
216+
* Version n°33
217+
*/
218+
V33 = 32,
219+
/**
220+
* Version n°34
221+
*/
222+
V34 = 33,
223+
/**
224+
* Version n°35
225+
*/
226+
V35 = 34,
227+
/**
228+
* Version n°36
229+
*/
230+
V36 = 35,
231+
/**
232+
* Version n°37
233+
*/
234+
V37 = 36,
235+
/**
236+
* Version n°38
237+
*/
238+
V38 = 37,
239+
/**
240+
* Version n°39
241+
*/
242+
V39 = 38,
243+
/**
244+
* Version n°40
245+
*/
246+
V40 = 39,
247+
}
248+
/**
63249
* Configuration for the SVG output.
64250
*/
65251
export class SvgOptions {
@@ -120,6 +306,18 @@ export class SvgOptions {
120306
*/
121307
image_position(image_position: Float64Array): SvgOptions;
122308
/**
309+
* Updates the error correction level of the QRCode (can increase the size of the QRCode)
310+
* @param {number} ecl
311+
* @returns {SvgOptions}
312+
*/
313+
ecl(ecl: number): SvgOptions;
314+
/**
315+
* Forces the version of the QRCode
316+
* @param {number} version
317+
* @returns {SvgOptions}
318+
*/
319+
version(version: number): SvgOptions;
320+
/**
123321
* Creates a new SvgOptions object.
124322
*/
125323
constructor();
@@ -128,6 +326,7 @@ export class SvgOptions {
128326
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
129327

130328
export interface InitOutput {
329+
readonly memory: WebAssembly.Memory;
131330
readonly qr: (a: number, b: number, c: number) => void;
132331
readonly __wbg_svgoptions_free: (a: number) => void;
133332
readonly svgoptions_shape: (a: number, b: number) => number;
@@ -139,15 +338,14 @@ export interface InitOutput {
139338
readonly svgoptions_image_background_shape: (a: number, b: number) => number;
140339
readonly svgoptions_image_size: (a: number, b: number, c: number) => number;
141340
readonly svgoptions_image_position: (a: number, b: number, c: number) => number;
341+
readonly svgoptions_ecl: (a: number, b: number) => number;
342+
readonly svgoptions_version: (a: number, b: number) => number;
142343
readonly svgoptions_new: () => number;
143344
readonly qr_svg: (a: number, b: number, c: number, d: number) => void;
144-
readonly memory: WebAssembly.Memory;
145345
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
146346
readonly __wbindgen_malloc: (a: number, b: number) => number;
147347
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
148348
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
149-
readonly __wbindgen_thread_destroy: (a: number, b: number) => void;
150-
readonly __wbindgen_start: () => void;
151349
}
152350

153351
export type SyncInitInput = BufferSource | WebAssembly.Module;
@@ -156,19 +354,17 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
156354
* a precompiled `WebAssembly.Module`.
157355
*
158356
* @param {SyncInitInput} module
159-
* @param {WebAssembly.Memory} maybe_memory
160357
*
161358
* @returns {InitOutput}
162359
*/
163-
export function initSync(module: SyncInitInput, maybe_memory?: WebAssembly.Memory): InitOutput;
360+
export function initSync(module: SyncInitInput): InitOutput;
164361

165362
/**
166363
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
167364
* for everything else, calls `WebAssembly.instantiate` directly.
168365
*
169366
* @param {InitInput | Promise<InitInput>} module_or_path
170-
* @param {WebAssembly.Memory} maybe_memory
171367
*
172368
* @returns {Promise<InitOutput>}
173369
*/
174-
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>, maybe_memory?: WebAssembly.Memory): Promise<InitOutput>;
370+
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;

0 commit comments

Comments
 (0)