{"_rev":"5-43469350d12c3c24575da2f642e817c8","time":{"created":"2026-01-20T16:29:16.257Z","modified":"2026-01-20T16:29:16.694Z","2.0.0":"2026-01-20T16:18:41.341Z","2.0.1":"2026-01-20T16:20:48.903Z","0.1.1":"2026-01-20T16:29:16.472Z"},"_id":"@allwcons/vite-plugin-jsw","name":"@allwcons/vite-plugin-jsw","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"@allwcons/vite-plugin-jsw","version":"0.1.1","description":"Vite plugin for JSW (JavaScript WebAssembly) compilation and integration","publishConfig":{"access":"public"},"type":"module","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./globals":"./globals.d.ts"},"engines":{"node":">=18.0.0"},"scripts":{"dev":"tsup --watch --onSuccess \"cp public/indexCastTransform.mjs dist/\"","build":"tsup && cp public/indexCastTransform.mjs dist/","lint":"tsc --noEmit","release":"standard-version","release:patch":"standard-version --release-as patch","release:minor":"standard-version --release-as minor","release:major":"standard-version --release-as major","prepublishOnly":"npm run build"},"keywords":["vite-plugin","assemblyscript","wasm","jsw","webassembly"],"author":"","license":"ISC","peerDependencies":{"assemblyscript":">=0.28.0","vite":">=5.0.0"},"devDependencies":{"@types/node":"^25.0.5","assemblyscript":"^0.28.9","standard-version":"^9.5.0","tsup":"^8.5.1","typescript":"^5.9.3","vite":"^7.3.1"},"gitHead":"3b477dac109df36bef75013e182003f825a3373a","_id":"@allwcons/vite-plugin-jsw@0.1.1","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-yqFQF5eG5/+P+P1xNDzT5pZ1yDgLPlD6fYRUxkkHeUvxaGoaoFf1JT1Ezu7xDrUbsUPuWsoatnLrsMBUgg4QFA==","shasum":"d4a941f852ad31c319e2de22acaf653d374bdd27","tarball":"https://registry.npmjs.org/@allwcons/vite-plugin-jsw/-/vite-plugin-jsw-0.1.1.tgz","fileCount":12,"unpackedSize":59875,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC0tN2YjIDClWeraADQ4yKbsPmDI/MB944pPTxR1z8VqwIgMT4bwdgI73rW9XiCc0iEa4iwAQy3UZ7I6kNxfGjKEKE="}]},"_npmUser":{"name":"allwcons","email":"allwcons@gmail.com"},"directories":{},"maintainers":[{"name":"allwcons","email":"allwcons@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vite-plugin-jsw_0.1.1_1768926556318_0.09450453352982535"},"_hasShrinkwrap":false}},"maintainers":[{"name":"allwcons","email":"allwcons@gmail.com"}],"description":"Vite plugin for JSW (JavaScript WebAssembly) compilation and integration","keywords":["vite-plugin","assemblyscript","wasm","jsw","webassembly"],"license":"ISC","readme":"# @allwcons/vite-plugin-jsw\n\nA Vite plugin that enables high-performance WebAssembly compilation from TypeScript-like syntax using the `\"use wasm\"` directive. It automatically bridges the gap between JavaScript's dynamic typing and AssemblyScript's strict typing.\n\n## Key Features\n\n- **Direct In-JS Compilation**: Mark any `.ts`, `.jsw`, or `.tsw` file with `\"use wasm\"` to compile it to WebAssembly seamlessly.\n- **Type Inference & Resolution**: Automatically injects return types and infers variable types using the TypeScript Compiler API, allowing you to write cleaner code that remains compatible with AssemblyScript.\n- **Auto-i32 Index Casting**: Automatically wraps array indices in `i32()` to prevent common AssemblyScript compilation errors when using `f64` (default `number`) as an index.\n- **Zero Configuration**: No complex `asconfig.json` setup required for individual modules; the plugin handles the compilation and glue generation (via `as-bind`) for you.\n- **Self-Contained Output**: The plugin bundles the WebAssembly binary as a base64 string directly within the JavaScript glue, eliminating the need for separate `.wasm` file loading logic.\n\n## Installation\n\n```bash\n# pnpm\npnpm add -D @allwcons/vite-plugin-jsw assemblyscript\n\n# npm\nnpm install --save-dev @allwcons/vite-plugin-jsw assemblyscript\n```\n\n## Setup\n\nAdd the plugin to your `vite.config.ts`:\n\n```typescript\nimport { defineConfig } from 'vite';\nimport jsw from '@allwcons/vite-plugin-jsw';\n\nexport default defineConfig({\n  plugins: [jsw()],\n});\n```\n\nTo take full advantage of AssemblyScript types in your IDE, include the global definitions in your `tsconfig.json` or `vite-env.d.ts`:\n\n```typescript\n// vite-env.d.ts\n/// <reference types=\"@allwcons/vite-plugin-jsw/globals\" />\n```\n\n## Usage\n\n### The `\"use wasm\"` Directive\n\nSimply add `\"use wasm\"` at the top of your file. The plugin will intercept the file, resolve implicit types, compile it to WASM, and return a JavaScript module with matched bindings.\n\n```typescript\n// math.ts\n\"use wasm\";\n\nexport function fib(n: number): number {\n  if (n <= 1) return n;\n  return fib(n - 1) + fib(n - 2);\n}\n\nexport function heavyMath(arr: Float64Array): void {\n  for (let i = 0; i < arr.length; i++) {\n    // Note: 'i' is treated as f64 (number) by default, \n    // but the plugin automatically casts it to i32 for array access.\n    arr[i] = Math.sqrt(arr[i]) * 2.0;\n  }\n}\n```\n\n### Type Mapping\n\nThe plugin provides a Type Resolver that maps standard TypeScript types to their AssemblyScript counterparts:\n- `number` $\\rightarrow$ `f64` (default)\n- `boolean` $\\rightarrow$ `bool`\n- Full support for TypedArrays: `Float64Array`, `Float32Array`, `Int32Array`, etc.\n\n### Automatic Enhancements\n\nThe plugin performs several AST-level transformations to ensure your code runs optimally in WASM without requiring verbose manual casting:\n\n1. **Return Type Injection**: \n   ```typescript\n   function add(a: f64, b: f64) { return a + b; }\n   // Becomes: function add(a: f64, b: f64): f64 { return a + b; }\n   ```\n\n2. **Variable Inference**:\n   ```typescript\n   let x = 1.5;\n   // Becomes: let x: f64 = 1.5;\n   ```\n\n3. **Index Casting**:\n   ```typescript\n   let value = myArr[i]; // where i is f64\n   // Becomes: let value = myArr[i32(i)];\n   ```\n\n## Development & Release\n\n### Semantic Versioning\nThis project uses `standard-version` for automated versioning and changelog management.\n\n```bash\n# Patch release (1.0.x)\nnpm run release:patch\n\n# Minor release (1.x.0)\nnpm run release:minor\n\n# Major release (x.0.0)\nnpm run release:major\n```\n\n## License\n\nISC\n","readmeFilename":"README.md"}