contributor-context
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/playbooks/integration/cloudflare-worker.md by scripts/build-agent-skill.mjs. Do not edit. -->
$ npx -y skills add crossbind/crossbind --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
<!-- GENERATED from docs/playbooks/integration/cloudflare-worker.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/playbooks/integration/cloudflare-worker.md by scripts/build-agent-skill.mjs. Do not edit. -->
> Persona 2 sub-playbook. The user's project is a Cloudflare Worker (or another edge runtime that follows the Workers compatibility model). Detection: `wrangler` in deps, `wrangler.{toml,jsonc,json}` at root.
Compile crossbind for the **edge** runtime so it loads inside a Worker (limited Node API surface, no DOM, no Workers' own `WebAssembly.compileStreaming` quirks). Wrangler dev + deploy ship the wasm + js loader as Worker assets.
| File | Role | |------|------| | `package.json` | + `crossbind`; `wrangler` already present | | `crossbind.config.{js,mjs}` *(new at root)* | Project-level crossbind config | | `wrangler.toml` | Already present; ensure `main` points at the user's entry | | `<entry>.js` (e.g. `index.js`) | Imports the crossbind loader, exports a Worker handler | | `dist/<name>.edge.{js,wasm}` | Build output, shipped by Wrangler |
pnpm add -D crossbind@beta pnpm add @crossbind/port-<name>@beta # optional # Build (target: edge) pnpm crossbind build -p wasm -a wasm32 -r st -e edge -b release # Dev pnpm wrangler dev # Deploy pnpm wrangler deploy
The build produces `dist/<name>.edge.js` + `dist/<name>.edge.wasm`. Wrangler bundles them as Worker assets.
Mirror `examples/cloud-cloudflare-worker/`.
`package.json` scripts (canonical):
{
"scripts": {
"build": "crossbind build -p wasm -a wasm32 -r st -e edge -b release",
"dev": "wrangler dev",
"deploy": "wrangler deploy"
}
}`wrangler.toml` (minimal):
name = "my-worker" main = "index.js" compatibility_date = "2024-09-08"
`crossbind.config.mjs`:
export default {
general: { name: 'my-worker' },
paths: {
config: import.meta.url,
},
};Worker entry `index.js`:
import initNative from './dist/my-worker.edge.js';
let crossbindPromise;
export default {
async fetch(request) {
crossbindPromise ??= initNative();
const Module = await crossbindPromise;
const result = Module.someFn();
return new Response(JSON.stringify({ result }), {
headers: { 'content-type': 'application/json' },
});
},
};Init lazily (`??=`) so the wasm compiles once per isolate, not per request.
crossbind's edge build uses `instantiateWasm` with the wasm bytes, **not** `fetch()` — Workers don't have arbitrary `fetch()` for local files. The build embeds the wasm via the bundler's import resolution. If you see "wasm not found", confirm:
**Not supported** in edge runtimes. SharedArrayBuffer is unavailable; Workers don't expose Web Workers / pthreads. Always build with `-r st`.
If the user insists on multithread, route them to a Node backend (`docs/playbooks/integration/nodejs.md`) or browser app (`docs/playbooks/integration/vite.md`).
Edge runtime adapter: `core/crossbind/src/assets/js-runtime/edge.js`.
Import C++ and Rust like JavaScript modules (WebAssembly & React Native)
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/api/app.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/build-state.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/conan.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/api/cpp-binding-rules.md by scripts/build-agent-skill.mjs. Do not edit. -->