1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Copyright 2026 Mahmoud Harmouch.
//
// Licensed under the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! # WASM Bindings
//!
//! `wasm-bindgen` exports for use in browser environments (vanilla JS,
//! Node.js with the WASM target).
//!
//! ## Why no `#[wasm_bindgen(start)]`?
//!
//! `lib.rs` deliberately does **not** register a `#[wasm_bindgen(start)]`
//! entry point. Library crates must not auto-run code at WASM module load
//! time because any host application (e.g. a Yew app) that **also** uses
//! `wasm-bindgen` will have its own startup routine, and two `start` symbols
//! in the same binary cause a link error.
//!
//! Instead, call [`init_panic_hook`] once from your own application startup:
//!
//! ```js
//! import init, { init_panic_hook } from "./cum_rs.js";
//! await init();
//! init_panic_hook(); // forward Rust panics to the browser console
//! ```
//!
//! ## Available Functions
//!
//! | Export | Description |
//! |--------|-------------|
//! | [`init_panic_hook`] | Sets up `console_error_panic_hook` (call once at startup). |
//! | [`clean_text_wasm`] | Layer-A clean of a JS string; returns a JSON object. |
//! | [`inspect_text_wasm`] | Layer-A inspection; returns a JSON object. |
//! | [`clean_bytes_wasm`] | Format-auto-detect clean of a `Uint8Array`. |
//! | [`inspect_bytes_wasm`] | Format-auto-detect inspection of a `Uint8Array`. |
//! | [`version`] | Returns the crate version string. |
//!
//! All functions serialise their return values as JSON via `serde_json` /
//! `serde-wasm-bindgen` so they are usable from vanilla JavaScript without any
//! additional Rust bindings.
use crate;
use crate;
use *;
/// Installs `console_error_panic_hook` so that Rust panics are forwarded to
/// the browser developer console as readable messages.
///
/// Call this **once** at startup from JavaScript:
/// ```js
/// import init, { init_panic_hook } from "./cum_rs.js";
/// await init();
/// init_panic_hook();
/// ```
/// Removes all Layer-A Unicode watermark carriers from a JavaScript string.
///
/// # Returns
/// A `JsValue` that is a JSON object:
/// ```json
/// { "cleaned": "...", "removed_count": 3, "replaced_count": 1, "summary": [...] }
/// ```
/// On error, throws a `JsValue` with the error message string.
/// Inspects a JavaScript string for Layer-A Unicode watermark carriers.
///
/// # Returns
/// A `JsValue` that is a JSON [`crate::types::TextInspectReport`].
/// On error, throws a `JsValue` with the error message string.
/// Removes all detectable watermarks from a `Uint8Array` (image or document).
///
/// The format is auto-detected from magic bytes.
///
/// # Returns
/// A `Uint8Array` containing the cleaned bytes.
/// On error, throws a `JsValue` with the error message string.
/// Inspects a `Uint8Array` (image or document) for watermark findings.
///
/// The format is auto-detected from magic bytes.
///
/// # Returns
/// A `JsValue` that is a JSON serialisation of [`crate::types::InspectOutput`].
/// On error, throws a `JsValue` with the error message string.
/// Returns the crate version string (e.g. `"0.1.0"`).