@wonfsy/wonfy-tools 0.1.2 → 0.2.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 CHANGED
@@ -3,6 +3,11 @@
3
3
  Simple collection of tools, mostly for personal usage.\
4
4
  You can checkout deployed version with UI on https://tools.won.fyi
5
5
 
6
+ > [!NOTE]
7
+ > Since 0.2.0 the stitcher runs its matching on the GPU through [wgpu](https://github.com/gfx-rs/wgpu).
8
+ > Natively it uses Vulkan/DX12/Metal; in the browser it requires WebGPU support.
9
+ > `stitch` is now async in both the Rust and JS APIs (`stitch_blocking` is available natively).
10
+
6
11
  #### You can install is as a cli
7
12
 
8
13
  ```sh
@@ -38,8 +43,9 @@ Then initiating the wasm before using any of the functionality.
38
43
  ```ts
39
44
  import initWasm, { stitch } from "@wonfsy/wonfy-tools";
40
45
 
41
- function main() {
42
- initWasm().then(() => stitch(/* params */))
46
+ async function main() {
47
+ await initWasm();
48
+ const result = await stitch(/* params */);
43
49
  }
44
50
  ```
45
51
 
@@ -50,7 +56,8 @@ If you're using a bundler, you're gonna have to tell the bundler to include the
50
56
  import initWasm, { stitch } from "@wonfsy/wonfy-tools";
51
57
  import wasmUrl from "@wonfsy/wonfy-tools/wonfy_tools_bg.wasm?url"
52
58
 
53
- function main() {
54
- initWasm({ module_or_path: wasmUrl }).then(() => stitch(/* params */))
59
+ async function main() {
60
+ await initWasm({ module_or_path: wasmUrl });
61
+ const result = await stitch(/* params */);
55
62
  }
56
63
  ```
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@wonfsy/wonfy-tools",
3
3
  "type": "module",
4
4
  "description": "Collection of tools for personal use, provides library and CLI.",
5
- "version": "0.1.2",
5
+ "version": "0.2.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -23,4 +23,4 @@
23
23
  "image",
24
24
  "stitching"
25
25
  ]
26
- }
26
+ }
package/wonfy_tools.d.ts CHANGED
@@ -1,91 +1,113 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function stitch(images: Uint8Array[], direction: string, order: string, window_size: number | null | undefined, match_mode: string | null | undefined, crop_padding: number | null | undefined, preview: Preview | null | undefined, format: EncodeFormat): StitchReturn;
4
- export function rgba_bytes_to_image(bytes: Uint8Array, width: number, height: number, format: EncodeFormat): ImageWithDHash;
5
- export function start(): void;
6
- export function encode_format_content_type(format: EncodeFormat): string;
7
- export function encode_format_file_extension(format: EncodeFormat): string;
3
+
8
4
  export enum EncodeFormat {
9
- Png = 0,
10
- Jpeg = 1,
11
- Gif = 2,
12
- WebP = 3,
13
- }
14
- export enum PreviewType {
15
- Resize = 0,
16
- MaxWidth = 1,
17
- MaxHeight = 2,
5
+ Png = 0,
6
+ Jpeg = 1,
7
+ Gif = 2,
8
+ WebP = 3,
18
9
  }
10
+
19
11
  export class ImageWithDHash {
20
- private constructor();
21
- free(): void;
22
- images(): [Uint8Array, BigInt];
12
+ private constructor();
13
+ free(): void;
14
+ [Symbol.dispose](): void;
15
+ images(): [Uint8Array, BigInt];
23
16
  }
17
+
24
18
  export class Preview {
25
- free(): void;
26
- constructor(type: PreviewType, value: number);
19
+ free(): void;
20
+ [Symbol.dispose](): void;
21
+ constructor(type: PreviewType, value: number);
22
+ }
23
+
24
+ export enum PreviewType {
25
+ Resize = 0,
26
+ MaxWidth = 1,
27
+ MaxHeight = 2,
27
28
  }
29
+
28
30
  export class StitchReturn {
29
- private constructor();
30
- free(): void;
31
- images(): [StitchedImage, StitchedImage?];
31
+ private constructor();
32
+ free(): void;
33
+ [Symbol.dispose](): void;
34
+ images(): [StitchedImage, StitchedImage?];
32
35
  }
36
+
33
37
  export class StitchedImage {
34
- private constructor();
35
- free(): void;
36
- toJson(): { image: Uint8Array, stitchPositions: Array<{ x: number, y: number }>, width: number, height: number };
37
- width: number;
38
- height: number;
38
+ private constructor();
39
+ free(): void;
40
+ [Symbol.dispose](): void;
41
+ toJson(): { image: Uint8Array, stitchPositions: Array<{ x: number, y: number }>, width: number, height: number };
42
+ height: number;
43
+ width: number;
39
44
  }
40
45
 
46
+ export function encode_format_content_type(format: EncodeFormat): string;
47
+
48
+ export function encode_format_file_extension(format: EncodeFormat): string;
49
+
50
+ export function rgba_bytes_to_image(bytes: Uint8Array, width: number, height: number, format: EncodeFormat): ImageWithDHash;
51
+
52
+ export function start(): void;
53
+
54
+ export function stitch(images: Uint8Array[], direction: string, order: string, window_size: number | null | undefined, match_mode: string | null | undefined, crop_padding: number | null | undefined, preview: Preview | null | undefined, format: EncodeFormat): Promise<StitchReturn>;
55
+
41
56
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
42
57
 
43
58
  export interface InitOutput {
44
- readonly memory: WebAssembly.Memory;
45
- readonly __wbg_preview_free: (a: number, b: number) => void;
46
- readonly preview_new: (a: number, b: number) => number;
47
- readonly __wbg_stitchedimage_free: (a: number, b: number) => void;
48
- readonly __wbg_get_stitchedimage_width: (a: number) => number;
49
- readonly __wbg_set_stitchedimage_width: (a: number, b: number) => void;
50
- readonly __wbg_get_stitchedimage_height: (a: number) => number;
51
- readonly __wbg_set_stitchedimage_height: (a: number, b: number) => void;
52
- readonly stitchedimage_toJson: (a: number) => any;
53
- readonly __wbg_stitchreturn_free: (a: number, b: number) => void;
54
- readonly stitchreturn_images: (a: number) => any;
55
- readonly stitch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number, number];
56
- readonly __wbg_imagewithdhash_free: (a: number, b: number) => void;
57
- readonly imagewithdhash_images: (a: number) => any;
58
- readonly rgba_bytes_to_image: (a: number, b: number, c: number, d: number, e: number) => number;
59
- readonly start: () => void;
60
- readonly encode_format_content_type: (a: number) => [number, number];
61
- readonly encode_format_file_extension: (a: number) => [number, number];
62
- readonly __wbindgen_exn_store: (a: number) => void;
63
- readonly __externref_table_alloc: () => number;
64
- readonly __wbindgen_export_2: WebAssembly.Table;
65
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
66
- readonly __wbindgen_malloc: (a: number, b: number) => number;
67
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
68
- readonly __externref_table_dealloc: (a: number) => void;
69
- readonly __wbindgen_start: () => void;
59
+ readonly memory: WebAssembly.Memory;
60
+ readonly __wbg_get_stitchedimage_height: (a: number) => number;
61
+ readonly __wbg_get_stitchedimage_width: (a: number) => number;
62
+ readonly __wbg_imagewithdhash_free: (a: number, b: number) => void;
63
+ readonly __wbg_preview_free: (a: number, b: number) => void;
64
+ readonly __wbg_set_stitchedimage_height: (a: number, b: number) => void;
65
+ readonly __wbg_set_stitchedimage_width: (a: number, b: number) => void;
66
+ readonly __wbg_stitchedimage_free: (a: number, b: number) => void;
67
+ readonly __wbg_stitchreturn_free: (a: number, b: number) => void;
68
+ readonly imagewithdhash_images: (a: number) => any;
69
+ readonly preview_new: (a: number, b: number) => number;
70
+ readonly rgba_bytes_to_image: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
71
+ readonly start: () => void;
72
+ readonly stitch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => any;
73
+ readonly stitchedimage_toJson: (a: number) => any;
74
+ readonly stitchreturn_images: (a: number) => any;
75
+ readonly encode_format_content_type: (a: number) => [number, number];
76
+ readonly encode_format_file_extension: (a: number) => [number, number];
77
+ readonly wasm_bindgen__convert__closures_____invoke__hb7851211c87e2b70: (a: number, b: number, c: any) => [number, number];
78
+ readonly wasm_bindgen__convert__closures_____invoke__h1e0146e5517296ad: (a: number, b: number, c: any) => [number, number];
79
+ readonly wasm_bindgen__convert__closures_____invoke__h1e0146e5517296ad_2: (a: number, b: number, c: any) => [number, number];
80
+ readonly wasm_bindgen__convert__closures_____invoke__h1e0146e5517296ad_3: (a: number, b: number, c: any) => [number, number];
81
+ readonly wasm_bindgen__convert__closures_____invoke__h2a7050afc147b47a: (a: number, b: number, c: any, d: any) => void;
82
+ readonly __wbindgen_exn_store: (a: number) => void;
83
+ readonly __externref_table_alloc: () => number;
84
+ readonly __wbindgen_externrefs: WebAssembly.Table;
85
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
86
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
87
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
88
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
89
+ readonly __externref_table_dealloc: (a: number) => void;
90
+ readonly __wbindgen_start: () => void;
70
91
  }
71
92
 
72
93
  export type SyncInitInput = BufferSource | WebAssembly.Module;
94
+
73
95
  /**
74
- * Instantiates the given `module`, which can either be bytes or
75
- * a precompiled `WebAssembly.Module`.
76
- *
77
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
78
- *
79
- * @returns {InitOutput}
80
- */
96
+ * Instantiates the given `module`, which can either be bytes or
97
+ * a precompiled `WebAssembly.Module`.
98
+ *
99
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
100
+ *
101
+ * @returns {InitOutput}
102
+ */
81
103
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
82
104
 
83
105
  /**
84
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
85
- * for everything else, calls `WebAssembly.instantiate` directly.
86
- *
87
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
88
- *
89
- * @returns {Promise<InitOutput>}
90
- */
106
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
107
+ * for everything else, calls `WebAssembly.instantiate` directly.
108
+ *
109
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
110
+ *
111
+ * @returns {Promise<InitOutput>}
112
+ */
91
113
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;