contributor-context
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/playbooks/integration/vanilla.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/vanilla.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/playbooks/integration/vanilla.md by scripts/build-agent-skill.mjs. Do not edit. -->
> Persona 2 sub-playbook. The user's project is plain HTML + JavaScript with no bundler. Detection: `index.html` at root (or `public/index.html`), no Vite/Webpack/Rspack/Rollup deps, possibly no `package.json` at all.
Build crossbind artifacts for the browser, ship them as static files, and load via plain `<script>` tags. Optional `serve.json` (or hosting config) sets COOP/COEP for multithread.
| File | Role | |------|------| | `package.json` | + `crossbind`, optional `@crossbind/port-<name>`, optional `serve` for local preview. Declare a `build` script that runs `crossbind build -e browser` | | `crossbind.config.{js,mjs}` *(new at root)* | Project-level crossbind config | | `index.html` | Loads `<script src="./dist/<name>...browser.js"></script>` and calls `initNative({ path: './dist' })` | | `src/native/` *(if user wraps own C++)* | `.h` + `.cpp` source | | `serve.json` *(local preview, optional)* | COOP/COEP headers for `serve` | | `dist/<name>-<target>.browser.{js,wasm}` | Build output |
pnpm add -D crossbind@beta pnpm add @crossbind/port-<name>@beta # optional pnpm add -D serve # optional, for local preview # Build pnpm crossbind build -p wasm -a wasm32 -r st -e browser -b release # Local preview (with COOP/COEP via serve.json) pnpm serve -c ./serve.json
Mirror `examples/web-vanilla/`.
`package.json`:
{
"scripts": {
"build": "crossbind build -p wasm -a wasm32 -r st -e browser -b release",
"preview": "serve -c ./serve.json"
},
"devDependencies": {
"crossbind": "^2.0.0",
"serve": "^14.0.0"
}
}`crossbind.config.mjs`:
export default {
general: { name: 'my-static-site' },
paths: {
config: import.meta.url,
output: 'dist',
},
};`index.html` (canonical pattern):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My static site</title>
<script src="./dist/my-static-site-wasm-wasm32-st-release.browser.js"></script>
<script>
initNative({ path: './dist' }).then(async ({ Native }) => {
document.querySelector('#out').innerHTML = await Native.sample();
});
</script>
</head>
<body>
<p id="out">loading…</p>
</body>
</html>The `path: './dist'` option tells the loader where to find `crossbind.wasm` / `crossbind.data.txt` relative to the page URL.
`serve.json` (for local preview, also matches Netlify/Cloudflare Pages `_headers` semantics):
{
"headers": [
{
"source": "**/*",
"headers": [
{ "key": "Cross-Origin-Opener-Policy", "value": "same-origin" },
{ "key": "Cross-Origin-Embedder-Policy", "value": "require-corp" }
]
}
]
}For `runtime: 'mt'`, the static host MUST set:
Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp
| Host | How | |------|-----| | Local `serve` | `serve.json` (above) | | Netlify / Cloudflare Pages | `public/_headers` with same content | | GitHub Pages | **Doesn't support custom headers.** Multithread won't work on GH Pages — use Cloudflare Pages or Netlify instead. | | Vercel | `vercel.json` `headers` array | | nginx | `add_header Cross-Origin-... always;` in `location` | | S3 + CloudFront | CloudFront response header policy |
For `runtime: 'st'`, no headers needed — works on any static host including GH Pages.
Browser runtime adapter: `core/crossbind/src/assets/js-runtime/browser.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. -->