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
140
141
142
143
144
145
146
147
148
149
//! WASM binding wrappers for crates/llmtxt-core public API.
//!
//! Each function delegates to the corresponding native Rust function
//! and serializes the result as JSON for JavaScript consumers. Pure
//! glue — no business logic lives here.
use *;
use crateclassify;
use crate::;
// Re-export crate-level WASM bindings from child modules so that Rust
// consumers can access them via the crate root when the `wasm` feature
// is active. (wasm-bindgen discovers them from the original modules
// directly; these re-exports serve Rust callers only.)
pub use crate;
pub use crate;
pub use crateretention_apply_wasm;
// ── 3-Way Merge (WASM) ──────────────────────────────────────────
/// WASM binding for the 3-way merge algorithm.
///
/// Takes `base`, `ours`, and `theirs` content strings.
/// Returns a JSON-serialised [`ThreeWayMergeResult`] on success, or
/// `{"error": "<message>"}` on serialization failure.
// ── Multi-way Diff (WASM) ────────────────────────────────────────
/// WASM binding for [`multi_way_diff`].
///
/// Takes base content and a JSON array of version strings.
/// Returns a JSON-serialised `MultiDiffResult` on success, or
/// `{"error": "<message>"}` on failure.
// ── Cherry-Pick Merge (WASM) ─────────────────────────────────────
/// WASM binding for [`cherry_pick_merge`].
///
/// Takes base content, a JSON versions map, and a JSON selection spec.
/// Returns a JSON-serialised `CherryPickResult` on success, or
/// `{"error": "<message>"}` on failure.
// ── Semantic Diff (WASM) ─────────────────────────────────────────
/// WASM binding for [`semantic_diff`].
///
/// `sections_a_json` and `sections_b_json` are JSON arrays of
/// `{ title, content, embedding: number[] }`.
/// Returns a JSON-serialised `SemanticDiffResult`, or `{"error":"..."}`.
// ── Semantic Consensus (WASM) ────────────────────────────────────
/// WASM binding for [`semantic_consensus`].
///
/// `reviews_json` is a JSON array of `{ reviewerId, content, embedding: number[] }`.
/// `threshold` is the minimum cosine similarity for two reviews to agree (e.g. 0.80).
/// Returns a JSON-serialised `SemanticConsensusResult`, or `{"error":"..."}`.
// ── Compression (WASM byte-level bindings) ───────────────────────
/// WASM binding: compress bytes using zstd, returning the compressed bytes.
///
/// Accepts a `Uint8Array` from JavaScript.
/// WASM binding: decompress zstd bytes, returning the raw decompressed bytes.
///
/// Accepts a `Uint8Array` from JavaScript.
// ── Similarity (WASM shims — delegate to similarity module) ────────
/// Compute character-level n-gram Jaccard similarity between two texts.
/// Returns 0.0 (no overlap) to 1.0 (identical). Default n=3.
///
/// WASM shim — delegates to [`similarity::text_similarity_jaccard`].
/// Compute n-gram Jaccard similarity with configurable gram size.
///
/// WASM shim — delegates to [`similarity::text_similarity_jaccard`].
// ── Classify (Wave-2: T826) ──────────────────────────────────────
/// WASM binding for [`classify::classify_content`].
///
/// Takes a byte slice (marshalled from JS as `Uint8Array` via
/// wasm-bindgen) and returns a JSON-serialised [`ClassificationResult`]
/// string. JS consumers parse the string back into an object.
///
/// Error handling: serialization failure returns `{"error":"..."}` —
/// callers should check for the `error` key before consuming.
///
/// # Examples
/// From JavaScript:
/// ```js
/// import { classify_content_wasm } from 'llmtxt';
/// const json = classify_content_wasm(new Uint8Array([0x25, 0x50, 0x44, 0x46]));
/// // json = '{"mimeType":"application/pdf","category":"binary","format":"pdf",...}'
/// ```