Skip to content

Commit

Permalink
feat: add option for ECL/Version in Wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanvivien committed Mar 12, 2024
1 parent f161032 commit 5ca8ba4
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 27 deletions.
210 changes: 203 additions & 7 deletions pkg/fast_qr.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,192 @@ export enum ImageBackgroundShape {
RoundedSquare = 2,
}
/**
* Error Correction Coding has 4 levels
*/
export enum ECL {
/**
* Low, 7%
*/
L = 0,
/**
* Medium, 15%
*/
M = 1,
/**
* Quartile, 25%
*/
Q = 2,
/**
* High, 30%
*/
H = 3,
}
/**
* Enum containing all possible `QRCode` versions
*/
export enum Version {
/**
* Version n°01
*/
V01 = 0,
/**
* Version n°02
*/
V02 = 1,
/**
* Version n°03
*/
V03 = 2,
/**
* Version n°04
*/
V04 = 3,
/**
* Version n°05
*/
V05 = 4,
/**
* Version n°06
*/
V06 = 5,
/**
* Version n°07
*/
V07 = 6,
/**
* Version n°08
*/
V08 = 7,
/**
* Version n°09
*/
V09 = 8,
/**
* Version n°10
*/
V10 = 9,
/**
* Version n°11
*/
V11 = 10,
/**
* Version n°12
*/
V12 = 11,
/**
* Version n°13
*/
V13 = 12,
/**
* Version n°14
*/
V14 = 13,
/**
* Version n°15
*/
V15 = 14,
/**
* Version n°16
*/
V16 = 15,
/**
* Version n°17
*/
V17 = 16,
/**
* Version n°18
*/
V18 = 17,
/**
* Version n°19
*/
V19 = 18,
/**
* Version n°20
*/
V20 = 19,
/**
* Version n°21
*/
V21 = 20,
/**
* Version n°22
*/
V22 = 21,
/**
* Version n°23
*/
V23 = 22,
/**
* Version n°24
*/
V24 = 23,
/**
* Version n°25
*/
V25 = 24,
/**
* Version n°26
*/
V26 = 25,
/**
* Version n°27
*/
V27 = 26,
/**
* Version n°28
*/
V28 = 27,
/**
* Version n°29
*/
V29 = 28,
/**
* Version n°30
*/
V30 = 29,
/**
* Version n°31
*/
V31 = 30,
/**
* Version n°32
*/
V32 = 31,
/**
* Version n°33
*/
V33 = 32,
/**
* Version n°34
*/
V34 = 33,
/**
* Version n°35
*/
V35 = 34,
/**
* Version n°36
*/
V36 = 35,
/**
* Version n°37
*/
V37 = 36,
/**
* Version n°38
*/
V38 = 37,
/**
* Version n°39
*/
V39 = 38,
/**
* Version n°40
*/
V40 = 39,
}
/**
* Configuration for the SVG output.
*/
export class SvgOptions {
Expand Down Expand Up @@ -120,6 +306,18 @@ export class SvgOptions {
*/
image_position(image_position: Float64Array): SvgOptions;
/**
* Updates the error correction level of the QRCode (can increase the size of the QRCode)
* @param {number} ecl
* @returns {SvgOptions}
*/
ecl(ecl: number): SvgOptions;
/**
* Forces the version of the QRCode
* @param {number} version
* @returns {SvgOptions}
*/
version(version: number): SvgOptions;
/**
* Creates a new SvgOptions object.
*/
constructor();
Expand All @@ -128,6 +326,7 @@ export class SvgOptions {
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly qr: (a: number, b: number, c: number) => void;
readonly __wbg_svgoptions_free: (a: number) => void;
readonly svgoptions_shape: (a: number, b: number) => number;
Expand All @@ -139,15 +338,14 @@ export interface InitOutput {
readonly svgoptions_image_background_shape: (a: number, b: number) => number;
readonly svgoptions_image_size: (a: number, b: number, c: number) => number;
readonly svgoptions_image_position: (a: number, b: number, c: number) => number;
readonly svgoptions_ecl: (a: number, b: number) => number;
readonly svgoptions_version: (a: number, b: number) => number;
readonly svgoptions_new: () => number;
readonly qr_svg: (a: number, b: number, c: number, d: number) => void;
readonly memory: WebAssembly.Memory;
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_thread_destroy: (a: number, b: number) => void;
readonly __wbindgen_start: () => void;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;
Expand All @@ -156,19 +354,17 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
* a precompiled `WebAssembly.Module`.
*
* @param {SyncInitInput} module
* @param {WebAssembly.Memory} maybe_memory
*
* @returns {InitOutput}
*/
export function initSync(module: SyncInitInput, maybe_memory?: WebAssembly.Memory): InitOutput;
export function initSync(module: SyncInitInput): InitOutput;

/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {InitInput | Promise<InitInput>} module_or_path
* @param {WebAssembly.Memory} maybe_memory
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>, maybe_memory?: WebAssembly.Memory): Promise<InitOutput>;
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
Loading

0 comments on commit 5ca8ba4

Please sign in to comment.