fratmscript 0.0.0-stage → 0.10.2
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/README.md +118 -2
- package/browser.d.ts +2 -0
- package/browser.js +44 -0
- package/index.d.ts +57 -0
- package/index.js +7 -0
- package/lib/api.js +51 -0
- package/lib/fetch-middleware.js +36 -0
- package/lib/node-hooks.js +32 -0
- package/lib/scripts.js +75 -0
- package/node.d.ts +3 -0
- package/node.js +7 -0
- package/package.json +66 -4
- package/vite.d.ts +27 -0
- package/vite.js +64 -0
- package/wasm/node/fratm_wasm.js +301 -0
- package/wasm/node/fratm_wasm_bg.wasm +0 -0
- package/wasm/node/package.json +1 -0
- package/wasm/web/fratm_wasm.js +389 -0
- package/wasm/web/fratm_wasm_bg.wasm +0 -0
- package/web.d.ts +12 -0
- package/web.js +38 -0
package/web.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// FratmScript compiler for browsers. Call `init()` once before `compile()`.
|
|
2
|
+
import initWasm, * as wasm from './wasm/web/fratm_wasm.js';
|
|
3
|
+
import { createApi } from './lib/api.js';
|
|
4
|
+
|
|
5
|
+
const api = createApi(wasm);
|
|
6
|
+
let ready = null;
|
|
7
|
+
let loaded = false;
|
|
8
|
+
|
|
9
|
+
export function init(input) {
|
|
10
|
+
ready ??= initWasm(input === undefined ? undefined : { module_or_path: input }).then(() => {
|
|
11
|
+
loaded = true;
|
|
12
|
+
});
|
|
13
|
+
return ready;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function assertLoaded() {
|
|
17
|
+
if (!loaded) throw new Error('fratmscript/web: await init() before using the compiler');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function compile(source, options) {
|
|
21
|
+
assertLoaded();
|
|
22
|
+
return api.compile(source, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function format(source) {
|
|
26
|
+
assertLoaded();
|
|
27
|
+
return api.format(source);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function version() {
|
|
31
|
+
assertLoaded();
|
|
32
|
+
return api.version();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function runtimeError(error) {
|
|
36
|
+
assertLoaded();
|
|
37
|
+
return api.runtimeError(error);
|
|
38
|
+
}
|