@tsvm/wasm-runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hybrid-builder.d.ts +3 -0
- package/dist/hybrid-builder.d.ts.map +1 -0
- package/dist/hybrid-builder.js +30 -0
- package/dist/hybrid-builder.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hybrid-builder.d.ts","sourceRoot":"","sources":["../src/hybrid-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqBnF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,GAAG,eAAe,CAYrG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { buildVMRuntime } from '@tsvm/vm-runtime';
|
|
2
|
+
const WASM_CORE_BYTES = [
|
|
3
|
+
0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 127, 3, 2, 1, 0, 7, 21, 1, 17, 116, 115, 118, 109, 95, 119, 97, 115, 109, 95, 98, 97, 99,
|
|
4
|
+
107, 101, 110, 100, 0, 0, 10, 6, 1, 4, 0, 65, 1, 11,
|
|
5
|
+
];
|
|
6
|
+
function createWasmBootstrap() {
|
|
7
|
+
return `
|
|
8
|
+
// WASM hybrid VM bootstrap. v1 validates a native WebAssembly core is available
|
|
9
|
+
// and keeps JS semantic execution as the correctness-preserving bridge.
|
|
10
|
+
const __tsvmWasmBytes = new Uint8Array([${WASM_CORE_BYTES.join(',')}]);
|
|
11
|
+
const __tsvmWasmModule = new WebAssembly.Module(__tsvmWasmBytes);
|
|
12
|
+
const __tsvmWasmInstance = new WebAssembly.Instance(__tsvmWasmModule, {});
|
|
13
|
+
if (__tsvmWasmInstance.exports.tsvm_wasm_backend() !== 1) {
|
|
14
|
+
throw new Error('TSXobf WASM backend bootstrap failed');
|
|
15
|
+
}
|
|
16
|
+
`.trim();
|
|
17
|
+
}
|
|
18
|
+
export function buildWasmHybridRuntime(module, config) {
|
|
19
|
+
const jsBundle = buildVMRuntime(module, config);
|
|
20
|
+
const wasmBootstrap = createWasmBootstrap();
|
|
21
|
+
const fullSource = `${wasmBootstrap}\n\n${jsBundle.fullSource}`;
|
|
22
|
+
return {
|
|
23
|
+
...jsBundle,
|
|
24
|
+
buildId: `${jsBundle.buildId}_wasm_hybrid`,
|
|
25
|
+
dispatchLoop: wasmBootstrap,
|
|
26
|
+
entryBootstrap: wasmBootstrap,
|
|
27
|
+
fullSource,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=hybrid-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hybrid-builder.js","sourceRoot":"","sources":["../src/hybrid-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,eAAe,GAAG;IACtB,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IACxI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE;CACpD,CAAC;AAEF,SAAS,mBAAmB;IAC1B,OAAO;;;0CAGiC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;CAMlE,CAAC,IAAI,EAAE,CAAC;AACT,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAsB,EAAE,MAAqB;IAClF,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAC;IAC5C,MAAM,UAAU,GAAG,GAAG,aAAa,OAAO,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEhE,OAAO;QACL,GAAG,QAAQ;QACX,OAAO,EAAE,GAAG,QAAQ,CAAC,OAAO,cAAc;QAC1C,YAAY,EAAE,aAAa;QAC3B,cAAc,EAAE,aAAa;QAC7B,UAAU;KACX,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsvm/wasm-runtime",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist",
|
|
6
|
+
"LICENSE"
|
|
7
|
+
],
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.json",
|
|
23
|
+
"test": "pnpm --dir ../.. exec vitest run packages/wasm-runtime/tests/**/*.test.ts --config vitest.config.mjs",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"clean": "rm -rf dist"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@tsvm/shared": "workspace:*",
|
|
29
|
+
"@tsvm/vm-runtime": "workspace:*"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"tsup": "^8.4.0",
|
|
33
|
+
"typescript": "^5.8.0"
|
|
34
|
+
}
|
|
35
|
+
}
|