wasm-constraints
/wasm-constraints
Opisuje ograniczenia buildu WASM dla crate xberg-wasm: cechy dla wasm32, API synchroniczne, limit rozmiaru HTML i build zoptymalizowany.
- Autor
- xberg-io ↗
- Repozytorium
- xberg ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 27.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 2
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Opisuje ograniczenia buildu WASM dla crate xberg-wasm: cechy dla wasm32, API synchroniczne, limit rozmiaru HTML i build zoptymalizowany.
Oryginalny opis (EN)
WASM build constraints for crates/xberg-wasm: wasm-target features, sync-only internal APIs, SyncExtractor, HTML size limit, size-optimized build. Use when building for wasm32 or debugging WASM build or runtime failures.
Jak działa
- Overview
- Feature Flags
- Critical Constraints
- Build Config
- API Pattern
- Critical Rules
Podgląd SKILL.md
---
type: Playbook
title: Wasm Constraints
description: "WASM build constraints for crates/xberg-wasm: wasm-target features, sync-only internal APIs, SyncExtractor, HTML size limit, size-optimized build. Use when building for wasm32 or debugging WASM build or runtime failures."
paths:
- "crates/xberg-wasm/**"
- "e2e/wasm/**"
x-ai-rulez:
kind: skill
id: wasm-constraints
metadata:
name: wasm-constraints
---
# WASM Build Constraints
## Overview
WASM target lives in `crates/xberg-wasm/`, built with wasm-bindgen over sync-only internal
APIs. Note that `crates/xberg-wasm/src/lib.rs` is Alef-generated — do not hand-edit it.
## Feature Flags
```toml
# crates/xberg/Cargo.toml
wasm-target = [
"no-ort-target",
"excel-wasm",
"ocr-wasm",
"layout-tract",
"auto-rotate-tract",
"ner-candle-wasm",
]
```
RT-DETR layout detection and PP-LCNet document orientation run through the pure-Rust `tract`
engine; weights are streamed in from JS, never fetched by Rust (`hf-hub`/`reqwest` are
native-only). Deliberately **no** tree-sitter: the 371-language grammar pack pushes the
browser `.wasm` past jsDelivr's 50 MB per-file cap.
## Critical Constraints
### 1. No Tokio Runtime
All operations must be synchronous internally. Use `#[cfg(not(feature = "tokio-runtime"))]`
paths.
### 2. Internal Sync Extractor Required
Every WASM-compatible built-in extractor must implement `SyncExtractor`
(`crates/xberg/src/extractors/mod.rs`). It is `pub(crate)`, so only in-crate extractors can
implement it — out-of-crate plugins cannot. This is not part of the public API; public callers
still use `extract` / `extract_batch`.
```rust
impl SyncExtractor for MyExtractor {
fn extract_sync(&self, content: &[u8], mime_type: &str, config: &ExtractionConfig)
-> Result<InternalDocument> { /* sync implementation */ }
}
```
There is no `as_sync_extractor()` method on `DocumentExtractor` — do not write one.
### 3. HTML Size Limit
```rust
// crates/xberg/src/extraction/html/stack_management.rs
pub const MAX_HTML_SIZE_BYTES: usize = 2 * 1024 * 1024; // 2 MB — stack constraint
```
## Build Config
```toml
# crates/xberg-wasm/Cargo.toml
[lib]
crate-type = ["cdylib"]
# root Cargo.toml
[profile.release.package.xberg-wasm]
opt-level = "z" # codegen-units = 1 comes from the global [profile.release]
```
## API Pattern
The generated surface exposes `async` wasm-bindgen functions over sync internals:
```rust
#[wasm_bindgen]
pub async fn extract(input: JsValue, config: JsValue) -> Result<WasmExtractionResult, JsValue>
```
Functions can be `async` for JS ergonomics; extraction underneath is synchronous.
## Critical Rules
1. **No tokio** — all operations synchronous.
2. **Implement `SyncExtractor`** for every WASM-compatible in-crate extractor.
3. **HTML capped at `MAX_HTML_SIZE_BYTES` (2 MB)** due to stack constraints.
4. **Size optimization** via `opt-level = "z"` on the package profile only.
5. **Gate WASM-specific code** with `#[cfg(target_arch = "wasm32")]`, and use the two-arm `cfg_attr` `async_trait` form on any plugin trait impl.
Pliki w paczce (2)
- SKILL.md 3 KB
- index.md 1 KB
Wersje
W bazie nie ma innych skilli o nazwie wasm-constraints.
Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.
Migawka bazy z 13.11.2026 · wersja paczki 71eb1fa19ae5 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 1 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 95wasm
Pomaga w integracji WebAssembly i WASI, modelu komponentów oraz kompilacji kodu Rust i Go do WASM. - 100kui
Buduje interfejsy GPUI i WASM z komponentami KUI z crates.io lub kopiowanego kodu, zwłaszcza przyciski. - 100flutter-wasm-web
Pomaga budować, optymalizować i wdrażać aplikacje Flutter Web dla WebAssembly (Wasm-GC) z nowoczesnym JS interop. - 100ascii-chat-wasm-development
Rozwija, debuguje i buduje moduły ascii-chat dla przeglądarki w Emscripten i WASM, w tym API Embind i renderer. - 100wasm-debugger
Diagnozuje błędy przeglądarkowego AILANG WASM, np. zawieszenia strony, ciche błędy loadModule i przepełnienia stosu. - 90agent-wasm-specialist
Działa jako subagent specjalista od WebAssembly: WASI, wasm-bindgen, Emscripten i kompilacja między językami, w tym optymalizacja wydajności WASM.