contributor-context
Contributor context for coding agents working in this repository. Human contributors should start with `README.md` and…
<!-- GENERATED from docs/playbooks/integration/vite.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/vite.md by scripts/build-agent-skill.mjs. Do not edit. -->
<!-- GENERATED from docs/playbooks/integration/vite.md by scripts/build-agent-skill.mjs. Do not edit. -->
> Persona 2 sub-playbook. The user's project uses Vite (`vite` in deps, `vite.config.{js,mjs,ts}` at root).
Add crossbind to a Vite project so:
| File | Role | |------|------| | `package.json` | + `@crossbind/plugin-vite` (devDependency), optional `@crossbind/port-<name>` | | `vite.config.{js,ts}` | Add `viteCrossbindPlugin()` to the `plugins` array | | `crossbind.config.js` *(new at project root)* | Project-level crossbind config: deps to consume, build target | | `src/native/` *(only if user wraps own C++)* | `.h` + `.cpp` source files (default location) | | Production headers config | Hosting-specific (Vercel `vercel.json`, Netlify `_headers`, nginx, …) — only for multithread builds |
# Install pnpm add -D @crossbind/plugin-vite@beta # Plus any prebuilt package the user wants to consume: pnpm add @crossbind/port-<name>@beta # Dev (HMR rebuilds wasm; COOP/COEP set automatically) pnpm dev # Production build pnpm build # Local preview of the production build (still gets COOP/COEP headers) pnpm preview
Mirror `examples/web-vue-vite/vite.config.js` (canonical):
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue'; // or react / svelte / solid
import viteCrossbindPlugin from '@crossbind/plugin-vite';
export default defineConfig({
plugins: [
vue(),
viteCrossbindPlugin(),
],
});The plugin handles:
`crossbind.config.js` at project root (only needed if wrapping own C++):
export default {
general: { name: 'my-app' },
target: { runtime: 'mt' }, // omit for single-thread default
};Dev/preview is handled by the plugin. **Production deploys are not.** The user's hosting layer must send:
Cross-Origin-Opener-Policy: same-origin Cross-Origin-Embedder-Policy: require-corp
Recipe per host:
| Host | File / setting | |------|----------------| | Vercel | `vercel.json` → `headers` array with both keys | | Netlify | `public/_headers` → `/*` block with both keys | | Cloudflare Pages | `public/_headers` (same syntax as Netlify) | | nginx | `add_header Cross-Origin-... always;` in the relevant `location` | | Static host (S3 + CDN) | CDN's response header rules | | Local `serve` | `serve.json` with `headers` array (see `examples/web-vue-vite/serve.json`) |
If the user picks `runtime: 'st'` (single-thread), none of this applies — no headers needed.
Plugin source: `plugins/vite/index.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. -->