@julclang/julc-vm-wasm 0.0.0-oidc-bootstrap.0 → 0.1.0-pre21

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BloxBean Project
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @julclang/julc-vm-wasm
2
+
3
+ JuLC's Plutus virtual machine, compiled to WebAssembly, for browsers and Node.js. It decodes, hashes, evaluates and
4
+ debugs Plutus V1, V2 and V3 scripts (UPLC 1.0.0 and 1.1.0), and applies parameters to them: `vm.applyParams` returns the
5
+ applied script and its hash under the language the request states (V1, V2 or V3). It runs in a worker, through
6
+ [`@julclang/wasm-client`](https://www.npmjs.com/package/@julclang/wasm-client), which this package depends on at its own
7
+ exact version. For the Java compiler, the decompiler and source debugging as well, install
8
+ [`@julclang/julc-wasm`](https://www.npmjs.com/package/@julclang/julc-wasm) instead.
9
+
10
+ **Experimental.** The JavaScript API is version 0 and may change in any release before 1.0; the release notes list
11
+ every change. JuLC is a research project: do not treat a result as proof that a contract is safe to deploy.
12
+
13
+ ## Use
14
+
15
+ ```js
16
+ import {createJulcVm} from '@julclang/julc-vm-wasm';
17
+
18
+ const julc = await createJulcVm();
19
+ try {
20
+ const {info} = await julc.vm.decode({script: {script: '46450101002499'}});
21
+ console.log(info.scriptHash);
22
+ const evaluation = await julc.vm.evaluate({script: {script: '46450101002499'}});
23
+ console.log(evaluation.status, evaluation.cpu, evaluation.mem);
24
+ // Apply the integer 42 to a parameterised script (the language is always stated).
25
+ const applied = await julc.vm.applyParams({language: 'V3', script: {script: '46450101002499'}, params: [{int: 42n}]});
26
+ console.log(applied.cborHex, applied.scriptHash);
27
+ } finally {
28
+ julc.dispose();
29
+ }
30
+ ```
31
+
32
+ Each client runs the engine in its own worker (`worker_threads` in Node.js); `dispose()` ends it. The package's version
33
+ is the JuLC release, and the client refuses to run an engine, a manifest or a runtime file of another release.
34
+ `createJulcVm(options)` takes `timeoutMs`, `loadTimeoutMs` and `workerFactory`; the engine's files are always this
35
+ package's. The types of every request and response are exported from the package root. The subpath `./engine` describes
36
+ the engine: its frozen `manifest`, `launcherUrl`, `moduleUrl` and `version`, and `engineFiles()`, which returns new
37
+ copies of them, for example for `@julclang/wasm-client`'s own `createJulc`.
38
+
39
+ ## Size and requirements
40
+
41
+ - The WebAssembly module is 14.5 MB (uncompressed). Serve it compressed: it compresses well.
42
+ - **First load:** a client was ready in about 0.2 s in Node.js 22 and 24 and in Chromium on an Apple-silicon
43
+ laptop, with the module already on disk or in the HTTP cache. Network transfer comes on top.
44
+ - **Browsers:** WebAssembly GC and exception references (`exnref`). Tested in Chromium 156.0.8078.4; Firefox and
45
+ Safari are not tested yet. BLS12-381 builtins are not available in WebAssembly.
46
+ - **TypeScript 5.0 or later** for the declarations, which re-export `@julclang/wasm-client`'s types with
47
+ `export type *`.
48
+ - **Node.js 22.3.0 or later.** Node 22 enables WebAssembly exception references only with
49
+ `--experimental-wasm-exnref`: the client checks for them before it starts its first worker and, when they are
50
+ missing, sets that flag with `v8.setFlagsFromString`. The flag is process-wide. Node 24 needs nothing. The engine
51
+ also loads inside your own `worker_threads` worker.
52
+ - **Content Security Policy:** `script-src 'self' 'wasm-unsafe-eval'`, on the page and on the responses of the worker
53
+ scripts, the runtime and the launcher (a worker script has its own policy). No `'unsafe-eval'` is needed.
54
+ - **Origins:** in a browser the worker loads the engine's files only from its own origin, which must not be opaque.
55
+ Other hosts, such as Electron with a custom scheme registered as standard, are untested; an Electron page loaded
56
+ from `file:` is refused.
57
+ - **Chrome extensions** (tested with an unpacked Manifest V3 extension page): Manifest V3's default policy does not
58
+ allow WebAssembly, so the manifest must:
59
+
60
+ ```json
61
+ "content_security_policy": {"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'"}
62
+ ```
63
+
64
+ ## Bundlers
65
+
66
+ The engine's files are named by `new URL('./engine/…', import.meta.url)` in `engine.js`, and the worker by
67
+ `new Worker(new URL('./julc-worker.js', import.meta.url))` in `@julclang/wasm-client`, so bundlers copy them.
68
+
69
+ - **Vite 8** needs no configuration. The **development servers of Vite 5 to 7** need both packages excluded from
70
+ dependency pre-bundling; their production builds need nothing:
71
+
72
+ ```js
73
+ // vite.config.js
74
+ export default {optimizeDeps: {exclude: ['@julclang/wasm-client', '@julclang/julc-vm-wasm']}};
75
+ ```
76
+ - **webpack 5** works with no configuration, but its Terser minifies the engine's launcher. To ship the launcher
77
+ unchanged, emit the engine files as assets and keep them out of minification:
78
+
79
+ ```js
80
+ // webpack.config.cjs
81
+ const TerserPlugin = require('terser-webpack-plugin');
82
+ module.exports = {
83
+ module: {rules: [{test: /[\\/]@julclang[\\/][^\\/]+[\\/]engine[\\/]/, type: 'asset/resource',
84
+ generator: {filename: 'engine/[name]-[contenthash:8][ext]'}}]},
85
+ optimization: {minimizer: [new TerserPlugin({exclude: /^engine\//})]},
86
+ };
87
+ ```
88
+ - **Plain `<script type="module">`** with an import map naming both packages' `index.js` works without a bundler.
89
+ - **Server bundles:** webpack with `target: 'node'` (its Terser minifies the launcher here too, which still works), and
90
+ Next.js with Turbopack (`next build`, `next dev` and `output: 'standalone'`), work as they are. **esbuild** does not
91
+ copy files named by `new URL`: keep the packages external (`--packages=external`, or `external: ['@julclang/*']`).
92
+ **Next.js with `--webpack`** rewrites the URLs: list both packages in `serverExternalPackages`.
93
+
94
+ Version 0.1.0-pre21. Source, issues and the design (ADR-077): https://github.com/bloxbean/julc
@@ -0,0 +1 @@
1
+ {"version":"90278477499e","launcher":"julc-vm-90278477499e.js","variant":"vm","api":0,"groups":["vm","debug"],"julcVersion":"0.1.0-pre21"}