{"_id":"@antjs.org/wasm","_rev":"2-6337c6f326d59ee1af98e8553ef9667e","name":"@antjs.org/wasm","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@antjs.org/wasm","version":"0.0.1","keywords":["ant","javascript","runtime","sandbox","wasm","webassembly"],"license":"MIT","_id":"@antjs.org/wasm@0.0.1","maintainers":[{"name":"themackabu","email":"theMackabu@gmail.com"}],"homepage":"https://github.com/theMackabu/ant#readme","bugs":{"url":"https://github.com/theMackabu/ant/issues"},"dist":{"shasum":"fdd6fcefdfc4d82cf50936a98fe8c10b14cc2499","tarball":"https://registry.npmjs.org/@antjs.org/wasm/-/wasm-0.0.1.tgz","fileCount":22,"integrity":"sha512-ThiWZanWQiyn9cgJVjG/CEbs08epE9mWNcteo3ASGb59ATr/fkHw4Ip/dfAxSdqxpgYu3HLnGJ+i8YbnRTGh5w==","signatures":[{"sig":"MEUCIQD/0pq7SZdC9uIjQZMrlOvarz60T11NRLPdXpexYJpW8QIgBzuEG4PXwYwS3KLn9ZQCFH6sCOceXmq89Ig3HbiQNa8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":2547195},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"fac17ccde02acf7b0bd3d3b0c9207f7cafce4b2a","scripts":{"test":"npm run build && node --test test/*.test.js","build":"node scripts/build.mjs","prepack":"npm run build","examples":"node examples/run-all.mjs","example:basic":"node examples/basic.mjs","example:limits":"node examples/limits-and-errors.mjs","example:rules-engine":"node examples/rules-engine.mjs","example:host-functions":"node examples/host-functions.mjs","example:isolated-runtimes":"node examples/isolated-runtimes.mjs"},"_npmUser":{"name":"themackabu","email":"theMackabu@gmail.com"},"repository":{"url":"git+https://github.com/theMackabu/ant.git","type":"git","directory":"packages/wasm"},"_npmVersion":"11.17.0","description":"Use the Ant Silver JavaScript engine through WebAssembly","directories":{},"_nodeVersion":"26.5.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/wasm_0.0.1_1787874640362_0.7757009746809871","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@antjs.org/wasm","version":"0.0.2","description":"Use the Ant Silver JavaScript engine through WebAssembly","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"node scripts/build.mjs","examples":"node examples/run-all.mjs","example:basic":"node examples/basic.mjs","example:host-functions":"node examples/host-functions.mjs","example:isolated-runtimes":"node examples/isolated-runtimes.mjs","example:limits":"node examples/limits-and-errors.mjs","example:rules-engine":"node examples/rules-engine.mjs","test":"npm run build && node --test test/*.test.js","prepack":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/theMackabu/ant.git","directory":"packages/wasm"},"keywords":["ant","javascript","runtime","sandbox","wasm","webassembly"],"license":"MIT","publishConfig":{"access":"public"},"engines":{"node":">=18"},"gitHead":"5fa71d6224ee92703faf1fc33fd5199751cdbd83","_id":"@antjs.org/wasm@0.0.2","bugs":{"url":"https://github.com/theMackabu/ant/issues"},"homepage":"https://github.com/theMackabu/ant#readme","_nodeVersion":"26.8.1","_npmVersion":"11.19.0","dist":{"integrity":"sha512-W0uDxL8+jZ7ekjFe/1k0HBApOMvdAfE5JAyn/FHV94F60fUzTGece/Pw21GSVg70qkZPYg7f3SA2QpiLWsli1w==","shasum":"5b776ed8d9cd4a38af015302c1ab1aa144dc85a9","tarball":"https://registry.npmjs.org/@antjs.org/wasm/-/wasm-0.0.2.tgz","fileCount":22,"unpackedSize":2574626,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCH0jlIyGApXCeCNWCO7IK3n4qGUsoZcoJFrWKPdigADgIhAJNGrknXDFcldeDQRLYkDRwsINtfRg8fgMKbCKfUtOjB"}]},"_npmUser":{"name":"themackabu","email":"theMackabu@gmail.com"},"directories":{},"maintainers":[{"name":"themackabu","email":"theMackabu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/wasm_0.0.2_1788896636694_0.5632786405679517"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-27T23:50:40.230Z","modified":"2026-09-08T19:43:57.071Z","0.0.1":"2026-08-27T23:50:40.563Z","0.0.2":"2026-09-08T19:43:56.875Z"},"bugs":{"url":"https://github.com/theMackabu/ant/issues"},"license":"MIT","homepage":"https://github.com/theMackabu/ant#readme","keywords":["ant","javascript","runtime","sandbox","wasm","webassembly"],"repository":{"type":"git","url":"git+https://github.com/theMackabu/ant.git","directory":"packages/wasm"},"description":"Use the Ant Silver JavaScript engine through WebAssembly","maintainers":[{"name":"themackabu","email":"theMackabu@gmail.com"}],"readme":"# @antjs.org/wasm\n\nEmbed the Ant Silver interpreter for sandboxing using WASM. Each `Ant`\ninstance owns its WebAssembly memory and keeps its own global state.\n\n```js\nimport { Ant } from '@antjs.org/wasm';\n\nconst ant = await Ant.create();\ntry {\n  const result = await ant.eval(`\n    Array.from({ length: 5 }, (_, i) => i ** 2)\n  `);\n  console.log(result); // [0, 1, 4, 9, 16]\n} finally {\n  ant.dispose();\n}\n```\n\nConfigure a hard memory ceiling, a guest execution timeout, and synchronous\nhost functions at creation time:\n\n```js\nimport { Ant } from '@antjs.org/wasm';\n\nconst ant = await Ant.create({\n  memoryLimit: 64 * 1024 * 1024,\n  timeout: 1_000,\n  globals: { greet: name => `Hello, ${name}!` }\n});\n\ntry {\n  const value = await ant.eval(`greet(\"Silver\")`);\n  console.log(value); // Hello, Silver!\n} finally {\n  ant.dispose();\n}\n```\n\n## API\n\n`Ant.create(options?)` asynchronously instantiates a fresh engine. The default\nmemory limit is 128 MiB. The minimum is 32 MiB and WebAssembly applies the\nlimit in 64 KiB pages, so `memoryLimit` must be page-aligned. A timeout of `0`\n(the default) disables the execution deadline.\n\n`ant.eval(source)` evaluates source with persistent global state and returns a\nPromise for its completion value. Call `dispose()` when explicit resource\nmanagement syntax is not available. On runtimes that implement explicit\nresource management, `using ant = await Ant.create()` disposes automatically.\n\nNumbers (including non-finite values and negative zero), booleans, strings,\nBigInts, `null`, `undefined`, arrays, and enumerable string-keyed object data\ncross the boundary. Cycles, symbols, and nested functions are rejected. A\nfunction supplied directly in `globals` can be called by guest code, but it\nmust return synchronously. Guest module imports, native APIs, subprocesses,\nnetworking, the package manager, and JIT compilation are not part of this\ninterpreter-only build.\n\nPromise reactions and resolved `await` continuations run at the evaluation\ncheckpoint. Promise objects themselves cannot cross the host boundary, and\nthis package does not provide timers or external asynchronous I/O inside the\nguest.\n\nThe timeout interrupts Silver bytecode execution. It cannot preempt a host\ncallback while that callback is running on the same JavaScript thread. Put an\ninstance in a Web Worker when the embedding must also isolate host callbacks\nfrom the page's main thread.\n\n## Examples\n\nThe [`examples`](./examples) gallery covers basic evaluation, host functions,\nstate isolation, a rules-engine pattern, limits, and error handling. In a\nrepository checkout, build once and then run all Node examples:\n\n```sh\nnpm run build\nnpm run examples\n```\n\n## Build\n\n```sh\nnpm run build\n```\n\nRun `npm test` for package validation.\n\nThe build downloads the host build of wasi-sdk 34, verifies its SHA-256 digest,\nand compiles a `wasm32-wasip1` reactor with Clang and wasm-ld. Set\n`WASI_SDK_PATH` to use an existing wasi-sdk 34 installation. Generated build,\ncache, and package artifacts stay under this package and are ignored by Git.\n\nThe published package contains the stripped `ant.wasm`, the Ant-owned ESM\nloader, and declarations. It contains no Emscripten loader. The build rejects\nany unreviewed Wasm import or export; the retained WASI Preview 1 calls are a\nsmall libc subset implemented by the loader without filesystem preopens or\nenvironment access.\n\nServe `ant.wasm` with `Content-Type: application/wasm` for streaming browser\ncompilation. The loader falls back to buffered compilation when that MIME type\nis unavailable.\n","readmeFilename":"README.md"}