@hew-lang/wasm 0.6.2 → 0.6.3
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 +32 -1
- package/package.json +3 -3
- package/wasm.d.ts +18 -1
- package/wasm.js +57 -1
- package/wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -28,7 +28,10 @@ The package exports JSON-string APIs for the current developer-tooling surface:
|
|
|
28
28
|
`code_actions`, and `get_keywords`.
|
|
29
29
|
|
|
30
30
|
Diagnostics include stable `phase`, `kind`, nested `span`, `message`, `notes`,
|
|
31
|
-
and `suggestions` fields
|
|
31
|
+
and `suggestions` fields, plus `source_hash` and producer-owned `fixes` (title,
|
|
32
|
+
applicability and byte-range edits). Pass diagnostics unchanged to `code_actions`;
|
|
33
|
+
human suggestions are prose. Stale snapshots and imported origins do not produce
|
|
34
|
+
root-buffer edits. The legacy `start_offset` / `end_offset` fields remain
|
|
32
35
|
for existing browser bridges.
|
|
33
36
|
|
|
34
37
|
## Compilation and execution
|
|
@@ -40,6 +43,34 @@ projection of that SIR, including ownership transfers, cleanup edges, actor
|
|
|
40
43
|
protocols and suspension points. The historical target argument is retained for
|
|
41
44
|
browser callers; it does not select a separate source-language profile.
|
|
42
45
|
|
|
46
|
+
`compileProjectToSandboxBytecode(requestJson, "sandbox-vm-export")` compiles
|
|
47
|
+
named documents through that same frontend. The request supplies an entry and
|
|
48
|
+
UTF-8 files, including ordinary package manifests when imports use package roots:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
const request = {
|
|
52
|
+
entry: "main.hew",
|
|
53
|
+
files: [
|
|
54
|
+
{
|
|
55
|
+
path: "main.hew",
|
|
56
|
+
source: "import user.nav; fn main() { println(nav.go()); }",
|
|
57
|
+
},
|
|
58
|
+
{ path: "user/hew.toml", source: '[package]\nname = "user"\n' },
|
|
59
|
+
{ path: "user/nav.hew", source: 'pub fn go() -> string { "MOVE" }' },
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
const compiled = JSON.parse(
|
|
63
|
+
compileProjectToSandboxBytecode(JSON.stringify(request)),
|
|
64
|
+
);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The response adds `resolved_files`: the sorted, unique entry and transitively
|
|
68
|
+
read supplied `.hew` sources. Unused documents, manifests and embedded standard
|
|
69
|
+
library sources are excluded. Diagnostics and their notes retain project-relative
|
|
70
|
+
file identity and file-local UTF-8 offsets. Paths stay inside the supplied project;
|
|
71
|
+
the embedded standard library cannot be replaced and missing files never read
|
|
72
|
+
the host filesystem. Native package and directory-module rules apply.
|
|
73
|
+
|
|
43
74
|
Execute the package with `runBytecode` from `@hew-lang/sandbox-vm`. Its loader
|
|
44
75
|
admits the package's declared operations before running any instruction. A
|
|
45
76
|
refusal distinguishes `native_only`, `not_implemented` and `invalid_package`.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@hew-lang/wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "WebAssembly bindings for Hew analysis and verified sandbox compilation",
|
|
5
|
-
"version": "0.6.
|
|
5
|
+
"version": "0.6.3",
|
|
6
6
|
"license": "MIT OR Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"webassembly"
|
|
27
27
|
],
|
|
28
28
|
"hewSource": {
|
|
29
|
-
"commit": "
|
|
30
|
-
"tag": "v0.6.
|
|
29
|
+
"commit": "97c1d865aa46afca1c75cf8ef2c1ea0d7f232471",
|
|
30
|
+
"tag": "v0.6.3",
|
|
31
31
|
"dirty": false
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
package/wasm.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export function analyze(source: string, files?: Map<any, any> | null): string;
|
|
|
14
14
|
* Get code actions for given diagnostics JSON. Returns JSON array of `CodeAction`.
|
|
15
15
|
*
|
|
16
16
|
* `diagnostics_json` should be a JSON array of `DiagnosticInfo` objects:
|
|
17
|
-
*
|
|
17
|
+
* Each object carries the `source_hash` and producer-owned `fixes` from
|
|
18
|
+
* `analyze` or `parse_source`. Stale source snapshots produce no actions.
|
|
18
19
|
*
|
|
19
20
|
* # Errors
|
|
20
21
|
*
|
|
@@ -23,6 +24,14 @@ export function analyze(source: string, files?: Map<any, any> | null): string;
|
|
|
23
24
|
*/
|
|
24
25
|
export function code_actions(source: string, diagnostics_json: string): string;
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Compile named browser documents through the canonical source graph.
|
|
29
|
+
*
|
|
30
|
+
* # Panics
|
|
31
|
+
* Panics if the compiler output cannot be serialized as JSON.
|
|
32
|
+
*/
|
|
33
|
+
export function compileProjectToSandboxBytecode(request: string, profile?: string | null): string;
|
|
34
|
+
|
|
26
35
|
/**
|
|
27
36
|
* Compile every test in one editor buffer once, returning one selected VM
|
|
28
37
|
* package per discovered declaration. The browser chooses the package by its
|
|
@@ -66,6 +75,12 @@ export function complete(source: string, offset: number): string;
|
|
|
66
75
|
*/
|
|
67
76
|
export function document_symbols(source: string): string;
|
|
68
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Execute a pure checked calendar operation. Integers cross JSON as decimal
|
|
80
|
+
* strings so the timestamp's full seconds range never passes through f64.
|
|
81
|
+
*/
|
|
82
|
+
export function executeCalendar(request: string): string;
|
|
83
|
+
|
|
69
84
|
/**
|
|
70
85
|
* Execute the compiler's typed codec plan using the shared native engine.
|
|
71
86
|
*/
|
|
@@ -212,10 +227,12 @@ export interface InitOutput {
|
|
|
212
227
|
readonly memory: WebAssembly.Memory;
|
|
213
228
|
readonly analyze: (a: number, b: number, c: number, d: number) => void;
|
|
214
229
|
readonly code_actions: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
230
|
+
readonly compileProjectToSandboxBytecode: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
215
231
|
readonly compileTestsToSandboxBytecode: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
216
232
|
readonly compileToSandboxBytecode: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
217
233
|
readonly complete: (a: number, b: number, c: number, d: number) => void;
|
|
218
234
|
readonly document_symbols: (a: number, b: number, c: number) => void;
|
|
235
|
+
readonly executeCalendar: (a: number, b: number, c: number) => void;
|
|
219
236
|
readonly executeCodec: (a: number, b: number, c: number) => void;
|
|
220
237
|
readonly expand_macro: (a: number, b: number, c: number, d: number) => void;
|
|
221
238
|
readonly find_references: (a: number, b: number, c: number, d: number) => void;
|
package/wasm.js
CHANGED
|
@@ -41,7 +41,8 @@ export function analyze(source, files) {
|
|
|
41
41
|
* Get code actions for given diagnostics JSON. Returns JSON array of `CodeAction`.
|
|
42
42
|
*
|
|
43
43
|
* `diagnostics_json` should be a JSON array of `DiagnosticInfo` objects:
|
|
44
|
-
*
|
|
44
|
+
* Each object carries the `source_hash` and producer-owned `fixes` from
|
|
45
|
+
* `analyze` or `parse_source`. Stale source snapshots produce no actions.
|
|
45
46
|
*
|
|
46
47
|
* # Errors
|
|
47
48
|
*
|
|
@@ -80,6 +81,36 @@ export function code_actions(source, diagnostics_json) {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Compile named browser documents through the canonical source graph.
|
|
86
|
+
*
|
|
87
|
+
* # Panics
|
|
88
|
+
* Panics if the compiler output cannot be serialized as JSON.
|
|
89
|
+
* @param {string} request
|
|
90
|
+
* @param {string | null} [profile]
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
export function compileProjectToSandboxBytecode(request, profile) {
|
|
94
|
+
let deferred3_0;
|
|
95
|
+
let deferred3_1;
|
|
96
|
+
try {
|
|
97
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
98
|
+
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
99
|
+
const len0 = WASM_VECTOR_LEN;
|
|
100
|
+
var ptr1 = isLikeNone(profile) ? 0 : passStringToWasm0(profile, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
101
|
+
var len1 = WASM_VECTOR_LEN;
|
|
102
|
+
wasm.compileProjectToSandboxBytecode(retptr, ptr0, len0, ptr1, len1);
|
|
103
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
104
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
105
|
+
deferred3_0 = r0;
|
|
106
|
+
deferred3_1 = r1;
|
|
107
|
+
return getStringFromWasm0(r0, r1);
|
|
108
|
+
} finally {
|
|
109
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
110
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
83
114
|
/**
|
|
84
115
|
* Compile every test in one editor buffer once, returning one selected VM
|
|
85
116
|
* package per discovered declaration. The browser chooses the package by its
|
|
@@ -223,6 +254,31 @@ export function document_symbols(source) {
|
|
|
223
254
|
}
|
|
224
255
|
}
|
|
225
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Execute a pure checked calendar operation. Integers cross JSON as decimal
|
|
259
|
+
* strings so the timestamp's full seconds range never passes through f64.
|
|
260
|
+
* @param {string} request
|
|
261
|
+
* @returns {string}
|
|
262
|
+
*/
|
|
263
|
+
export function executeCalendar(request) {
|
|
264
|
+
let deferred2_0;
|
|
265
|
+
let deferred2_1;
|
|
266
|
+
try {
|
|
267
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
268
|
+
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
269
|
+
const len0 = WASM_VECTOR_LEN;
|
|
270
|
+
wasm.executeCalendar(retptr, ptr0, len0);
|
|
271
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
272
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
273
|
+
deferred2_0 = r0;
|
|
274
|
+
deferred2_1 = r1;
|
|
275
|
+
return getStringFromWasm0(r0, r1);
|
|
276
|
+
} finally {
|
|
277
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
278
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
226
282
|
/**
|
|
227
283
|
* Execute the compiler's typed codec plan using the shared native engine.
|
|
228
284
|
* @param {string} request
|
package/wasm_bg.wasm
CHANGED
|
Binary file
|