{"id":22836605,"url":"https://github.com/hexxone/wasc-worker","last_synced_at":"2026-02-12T15:04:40.567Z","repository":{"id":267778976,"uuid":"875410511","full_name":"hexxone/wasc-worker","owner":"hexxone","description":" Move an AssemblyScript module into its own thread","archived":false,"fork":false,"pushed_at":"2024-10-20T12:00:23.000Z","size":241,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-09T18:05:34.537Z","etag":null,"topics":["assemblyscript","thread","typescript","wasm","web-worker","webpack-plugin","webworkers"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexxone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-19T22:36:28.000Z","updated_at":"2024-10-27T08:27:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"104afa9c-6ecd-4538-bf38-2f95493cf738","html_url":"https://github.com/hexxone/wasc-worker","commit_stats":null,"previous_names":["hexxone/wasc-worker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hexxone/wasc-worker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexxone%2Fwasc-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexxone%2Fwasc-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexxone%2Fwasc-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexxone%2Fwasc-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexxone","download_url":"https://codeload.github.com/hexxone/wasc-worker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexxone%2Fwasc-worker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29369400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T08:51:36.827Z","status":"ssl_error","status_checked_at":"2026-02-12T08:51:26.849Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assemblyscript","thread","typescript","wasm","web-worker","webpack-plugin","webworkers"],"created_at":"2024-12-12T23:11:48.355Z","updated_at":"2026-02-12T15:04:40.548Z","avatar_url":"https://github.com/hexxone.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [wasc-worker](https://github.com/hexxone/wasc-worker)\n\nis a custom fork of:\n\n## [wasm-worker](https://github.com/mbasso/wasm-worker)\n\n### specifically designed for AssemblyScript \u0026 TypeScript\n\n#### Please see below for the original Author(s) and Copyright\n\n## How to build AssemblyScript modules and use them in Workers\n\nThis repository includes a WebPack Plugin called \"WascBuilderPlugin\" for compiling AssemblyScript (a Typescript-variant) to WebAssembly modules. =\u003e Usage =\u003e Compiling\n\nAt the same time, it can be used to load and run the module in a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers). =\u003e Usage =\u003e Running\n\nMain target are browser environments.\n\n## Install\n\nYou can \"install\" wasc-worker using this method for now:\n\n```bash\ngit submodule add path/to/put/wasc-worker https://github.com/hexxone/wasc-worker\n```\n\nAt a later time, there might be a node-package.\nBut for now everything is \"experimental\"..\n\n## Usage\n\n### 1. Compiling\n\nNotice: the extension \".asc\" is used for determining the compile-targets in the next step.\nYou cannot mix different extensions.\nE.g.: you cant require \"utils.ts\" from \"index.asc\".\nIf this collides with your naming scheme, you will have to alter the settings in Step 2.\n\nSo.. suppose you have an \"add.asc\" file with this content:\n\n```asc\n\nexport function add(a: i32, b: i32): i32 {\n  return a + b;\n}\n```\n\nFor building, you simply need to include the Plugin in your `webpack.config.js` like so:\n\n```js\n\nconst WascBuilderPlugin = require('....wasc-worker/WascBuilderPlugin');\n\n...\n\nplugins: [\n    ...\n    // AssemblyScript compiler\n    new WascBuilderPlugin({\n      production: false, // decides whether to optimize OR generate a .map file\n      basedir: \"../../../../assembly\", // will compile all matched modules in this folder (recursive)\n      modules: [\"CloudGen.asc\"], // modules to compile\n      cleanup: true // decides if the temp-dir is cleaned after compiling (debugging?)\n      shared: true, // additionally compile with \"shared\" memory flag\n    }),\n    ...\n  ]\n\n```\n\nRunning your Webpack build should now also print something like this:\n\n```bash\n$ yarn dbg\n[WasmPlugin] Gathering Infos....\n[WasmPlugin] Compile debug: add.asc\nI/O Read   :     0.042 ms  n=2\nI/O Write  :     1.337 ms  n=2\nParse      :   299.502 ms  n=71\nInitialize :    14.957 ms  n=1\nCompile    :   147.420 ms  n=1\nEmit       :   121.151 ms  n=1\nValidate   :     6.969 ms  n=1\nOptimize   :     0.584 ms  n=1\nTransform  :          n/a  n=0\n[WasmPlugin] Success: add.wasm\n[WasmPlugin] Cleaning...\n[WasmPlugin] delete: add.wasm\n[WasmPlugin] delete: add.wasm.map\n[WasmPlugin] finished.\n```\n\nNow you should have the \"add.wasm\" module in your webpack compilation folder.\n\nThe WebAssembly module should export the \"add\"-function, \"memory\" and [AssemblyScript runtime](https://www.assemblyscript.org/loader.html#module-instance-utility).\n\n### 2. Running\n\nAssume the built example module from Step 1.\n\n```ts\nimport wascWorker from 'wasc-worker';\n\n// Method 1:\nwascWorker('add.wasm')\n  .then(module =\u003e {\n    return module.exports.add(1, 2);\n  })\n  .then(sum =\u003e {\n    console.log('1 + 2 = ' + sum);\n  })\n  .catch(ex =\u003e {\n    // ex is a string that represents the exception\n    console.error(ex);\n  });\n\n// Method 2\n// run js functions inside the worker thread/context\n// to access importObject for example\nwascWorker('add.wasm')\n  .then(module =\u003e {\n    return module.run(({ module, instance, importObject, params }) =\u003e {\n      const { exports } = instance;\n      \n      const sum = exports.add(...params);\n      return '1 + 2 = ' + sum;\n    }, [1, 2]);\n  })\n  .then(result =\u003e {\n    console.log(result);\n  });\n```\n\n### API\n\nAlmost everything has been made type-safe and should be self-explanatory.\n\n#### [Documentation](https://hexxone.github.io/we_utils/)\n\n## Supported environments\n\n`wasc-worker` uses [fetch](https://developer.mozilla.org/it/docs/Web/API/Fetch_API),\n[WebWorker's](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) and\n[WebAssembly](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly)\nAPIs.\n\nThere is a fallback included for Web-Workers, but you will need an up-to-date major Browser (like Chrome/Firefox).\n\nNode.js usage is NOT explicitly implemented \u0026 was NOT tested, so you probably have to polyfill it.\n\n### Content-Security-Policy\n\nYou will also need these HTTP Headers due to [Security Requirements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements) - following 'Spectre' from 2018.\n\n```\nhttps: true\nCross-Origin-Opener-Policy: same-origin\nCross-Origin-Embedder-Policy: require-corp\n```\n\n## Inspiration\n\nThe project is inspired by [wasm-worker](https://github.com/mbasso/wasm-worker).\n\n## Original Change Log\n\n\u003e The github Code of Conduct applies to this project.\n\nThis project adhered to [Semantic Versioning](http://semver.org/).\n\nEvery old release, along with the migration instructions, is documented on the Github [Releases](https://github.com/mbasso/wasm-worker/releases) page.\n\n## Authors\n\n**Matteo Basso**\n\n- [github/mbasso](https://github.com/mbasso)\n- [@teo_basso](https://twitter.com/teo_basso)\n\n**hexxone**\n\n- [github/hexxone](https://github.com/hexxone)\n\n## Copyright and License\n\nOriginal Author:\nCopyright (c) 2018, Matteo Basso.\n\nwasm-worker source code is licensed under the [MIT License](https://github.com/mbasso/wasm-worker/blob/master/LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexxone%2Fwasc-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexxone%2Fwasc-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexxone%2Fwasc-worker/lists"}