frameassembly-wasm 0.0.0-stage → 1.4.1
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 +21 -0
- package/README.md +170 -2
- package/frameassembly_wasm.d.ts +72 -0
- package/frameassembly_wasm.js +312 -0
- package/frameassembly_wasm_bg.wasm +0 -0
- package/package.json +30 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Steve Winschel
|
|
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
CHANGED
|
@@ -1,3 +1,171 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FrameAssembly WebAssembly Compiler (`frameassembly-wasm` v1.4.1)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
High-performance WebAssembly compiler, frame inspector, and UTF-16 IDE diagnostics for **FrameAssembly (`.fasm`)** — the deterministic domain-specific language for synthesizing standards-compliant network packets (L2–L7) and PCAPNG captures in browser applications, web playgrounds, and Node.js runtimes. *(Note: FrameAssembly is a network protocol DSL, not x86 Flat Assembler).*
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Client-Side `.fasm` to `.pcapng` Compilation in the Browser & Node.js
|
|
8
|
+
|
|
9
|
+
`frameassembly-wasm` compiles the complete FrameAssembly Rust compiler directly to WebAssembly, generating deterministic, nanosecond-precision `.pcapng` byte streams and real-time Monaco/CodeMirror syntax diagnostics entirely in the browser or Node.js—with no backend server, Python runtime, or native `libpcap` dependencies required:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import init, {
|
|
13
|
+
compile_fasm_to_pcapng,
|
|
14
|
+
validate_fasm,
|
|
15
|
+
inspect_fasm,
|
|
16
|
+
} from "frameassembly-wasm";
|
|
17
|
+
|
|
18
|
+
// Initialize WASM module once at startup
|
|
19
|
+
await init();
|
|
20
|
+
|
|
21
|
+
const source = `HOST client { IP 192.168.1.10 MAC 00:11:22:33:44:55 }
|
|
22
|
+
HOST server { IP 8.8.8.8 MAC aa:bb:cc:dd:ee:ff }
|
|
23
|
+
|
|
24
|
+
FLOW dns_query(c, s) {
|
|
25
|
+
c -> s DNS QUERY TXID 0x1234 QNAME "example.com" QTYPE "A" WAIT 1ms
|
|
26
|
+
c <- s DNS RESPONSE TXID 0x1234 QNAME "example.com" QTYPE "A" RDATA "93.184.216.34" WAIT 1ms
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
COMPILE {
|
|
30
|
+
dns_query(client, server)
|
|
31
|
+
}`;
|
|
32
|
+
|
|
33
|
+
// 1. Validate syntax & semantics for Monaco / CodeMirror editor markers
|
|
34
|
+
const diagnostics = validate_fasm(source);
|
|
35
|
+
if (diagnostics.length === 0) {
|
|
36
|
+
// 2. Inspect individual packet headers and hex payloads
|
|
37
|
+
const previews = inspect_fasm(source);
|
|
38
|
+
console.log(`Synthesized ${previews.length} frames.`);
|
|
39
|
+
|
|
40
|
+
// 3. Compile to binary PCAPNG Uint8Array
|
|
41
|
+
const pcapngBytes = compile_fasm_to_pcapng(source);
|
|
42
|
+
const blob = new Blob([pcapngBytes], { type: "application/vnd.tcpdump.pcap" });
|
|
43
|
+
console.log(`Generated PCAPNG: ${blob.size} bytes`);
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install frameassembly-wasm
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install frameassembly-wasm
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Browser CDN Usage (No Bundler)
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<script type="module">
|
|
63
|
+
import init, {
|
|
64
|
+
validate_fasm,
|
|
65
|
+
inspect_fasm,
|
|
66
|
+
compile_fasm_to_pcapng,
|
|
67
|
+
} from "https://cdn.jsdelivr.net/npm/frameassembly-wasm@1.4.1/frameassembly_wasm.js";
|
|
68
|
+
|
|
69
|
+
await init();
|
|
70
|
+
console.log("FrameAssembly WebAssembly engine loaded successfully.");
|
|
71
|
+
</script>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Initialization (Vite, React, Next.js & Google AI Studio)
|
|
77
|
+
|
|
78
|
+
Import the WebAssembly binary URL explicitly with `?url` so Vite, Webpack 5, and Next.js serve the `.wasm` asset cleanly in both development and production builds:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import init, {
|
|
82
|
+
validate_fasm,
|
|
83
|
+
inspect_fasm,
|
|
84
|
+
compile_fasm_to_pcapng,
|
|
85
|
+
type IdeDiagnostic,
|
|
86
|
+
type PacketPreview,
|
|
87
|
+
} from "frameassembly-wasm";
|
|
88
|
+
import wasmUrl from "frameassembly-wasm/frameassembly_wasm_bg.wasm?url";
|
|
89
|
+
|
|
90
|
+
// Call once at application startup (idempotent)
|
|
91
|
+
await init({ module_or_path: wasmUrl });
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## API Reference
|
|
97
|
+
|
|
98
|
+
### `validate_fasm(source: string): IdeDiagnostic[]`
|
|
99
|
+
Parses and validates `.fasm` source code, returning zero-based UTF-16 line and column spans ready for Monaco Editor or CodeMirror 6 diagnostic markers. Returns an empty array `[]` when the source compiles cleanly.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
interface IdeDiagnostic {
|
|
103
|
+
start_line: number; // 0-based UTF-16 line index
|
|
104
|
+
start_col: number; // 0-based UTF-16 character column
|
|
105
|
+
end_line: number; // 0-based UTF-16 line index
|
|
106
|
+
end_col: number; // 0-based UTF-16 character column
|
|
107
|
+
message: string; // Human-readable diagnostic message
|
|
108
|
+
help?: string; // Actionable "Did you mean...?" remediation hint
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### `inspect_fasm(source: string): PacketPreview[]`
|
|
113
|
+
Compiles `.fasm` source code into an array of packet inspection summaries, including relative nanosecond timestamps, frame lengths, and lowercase space-delimited hex byte dumps. Throws a JavaScript `Error` if compilation fails.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
interface PacketPreview {
|
|
117
|
+
index: number; // 0-based frame index
|
|
118
|
+
timestamp_ms: number; // Relative timestamp in milliseconds
|
|
119
|
+
length: number; // Total packet length in bytes
|
|
120
|
+
hex: string; // Space-separated lowercase hex byte dump
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### `compile_fasm_to_pcapng(source: string): Uint8Array`
|
|
125
|
+
Compiles `.fasm` source code into a binary `Uint8Array` containing a valid, standards-compliant PCAPNG byte stream with nanosecond timestamp precision (`IfTsResol = 9`). Throws a JavaScript `Error` with rich diagnostic context if compilation fails.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Complete Browser Playground & Download Example
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import init, { compile_fasm_to_pcapng, validate_fasm } from "frameassembly-wasm";
|
|
133
|
+
|
|
134
|
+
export async function downloadCapture(fasmCode: string, filename = "capture.pcapng") {
|
|
135
|
+
await init();
|
|
136
|
+
|
|
137
|
+
const errors = validate_fasm(fasmCode);
|
|
138
|
+
if (errors.length > 0) {
|
|
139
|
+
throw new Error(`Compilation error: ${errors[0].message}`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const pcapng = compile_fasm_to_pcapng(fasmCode);
|
|
143
|
+
const blob = new Blob([pcapng], { type: "application/vnd.tcpdump.pcap" });
|
|
144
|
+
const url = URL.createObjectURL(blob);
|
|
145
|
+
|
|
146
|
+
const a = document.createElement("a");
|
|
147
|
+
a.href = url;
|
|
148
|
+
a.download = filename;
|
|
149
|
+
document.body.appendChild(a);
|
|
150
|
+
a.click();
|
|
151
|
+
document.body.removeChild(a);
|
|
152
|
+
URL.revokeObjectURL(url);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Features & Engine Capabilities
|
|
159
|
+
|
|
160
|
+
- **Zero Server Dependencies**: Executes 100% locally in WebAssembly inside Chrome, Firefox, Safari, Edge, Web Workers, and Node.js.
|
|
161
|
+
- **81 Native Protocols**: Complete coverage across L2–L7 (Ethernet, 802.1Q VLAN, QinQ, MPLS, ARP, IPv4/IPv6, ICMP, TCP, UDP, SCTP, SNMPv1/v2c/v3 USM, DNS, DHCP, HTTP, TLS, Modbus, DNP3, and more).
|
|
162
|
+
- **Nanosecond Fidelity**: Compiles deterministic PCAPNG captures with nanosecond-resolution Section and Interface Description Blocks (`IfTsResol(9)`).
|
|
163
|
+
- **Sub-Millisecond Compilation**: Small to medium captures compile in `< 5ms`, making real-time live typing diagnostics instantaneous in web editors.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Disambiguation: FrameAssembly vs. Flat Assembler
|
|
168
|
+
|
|
169
|
+
**FrameAssembly** (`.fasm`, media type `text/vnd.frameassembly`) is a domain-specific network protocol specification language for synthesizing deterministic `.pcap` and `.pcapng` packet captures. It is completely unrelated to x86 Flat Assembler (`fasm.net`) and SymbiFlow / F4PGA FPGA bitstream FASM tools.
|
|
170
|
+
|
|
171
|
+
Full documentation, grammar specifications, and 2,611 verified examples: https://github.com/SteveWinschel/FrameAssembly
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export interface IdeDiagnostic {
|
|
5
|
+
start_line: number;
|
|
6
|
+
start_col: number;
|
|
7
|
+
end_line: number;
|
|
8
|
+
end_col: number;
|
|
9
|
+
message: string;
|
|
10
|
+
help?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PacketPreview {
|
|
14
|
+
index: number;
|
|
15
|
+
timestamp_ms: number;
|
|
16
|
+
length: number;
|
|
17
|
+
hex: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Compiles .fasm source into a standards-compliant PCAPNG byte array (JS Uint8Array).
|
|
24
|
+
*/
|
|
25
|
+
export function compile_fasm_to_pcapng(source: string): Uint8Array;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns decoded frame metadata and hex strings for a browser packet inspector.
|
|
29
|
+
*/
|
|
30
|
+
export function inspect_fasm(source: string): PacketPreview[];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Validates .fasm source and returns UTF-16 line/column diagnostics for Monaco/CodeMirror.
|
|
34
|
+
*/
|
|
35
|
+
export function validate_fasm(source: string): IdeDiagnostic[];
|
|
36
|
+
|
|
37
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
38
|
+
|
|
39
|
+
export interface InitOutput {
|
|
40
|
+
readonly memory: WebAssembly.Memory;
|
|
41
|
+
readonly compile_fasm_to_pcapng: (a: number, b: number) => [number, number, number, number];
|
|
42
|
+
readonly inspect_fasm: (a: number, b: number) => [number, number, number];
|
|
43
|
+
readonly validate_fasm: (a: number, b: number) => [number, number, number];
|
|
44
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
45
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
46
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
47
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
48
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
49
|
+
readonly __wbindgen_start: () => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
56
|
+
* a precompiled `WebAssembly.Module`.
|
|
57
|
+
*
|
|
58
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
59
|
+
*
|
|
60
|
+
* @returns {InitOutput}
|
|
61
|
+
*/
|
|
62
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
66
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
67
|
+
*
|
|
68
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
69
|
+
*
|
|
70
|
+
* @returns {Promise<InitOutput>}
|
|
71
|
+
*/
|
|
72
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/* @ts-self-types="./frameassembly_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compiles .fasm source into a standards-compliant PCAPNG byte array (JS Uint8Array).
|
|
5
|
+
* @param {string} source
|
|
6
|
+
* @returns {Uint8Array}
|
|
7
|
+
*/
|
|
8
|
+
export function compile_fasm_to_pcapng(source) {
|
|
9
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
10
|
+
const len0 = WASM_VECTOR_LEN;
|
|
11
|
+
const ret = wasm.compile_fasm_to_pcapng(ptr0, len0);
|
|
12
|
+
if (ret[3]) {
|
|
13
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
14
|
+
}
|
|
15
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
16
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
17
|
+
return v2;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns decoded frame metadata and hex strings for a browser packet inspector.
|
|
22
|
+
* @param {string} source
|
|
23
|
+
* @returns {PacketPreview[]}
|
|
24
|
+
*/
|
|
25
|
+
export function inspect_fasm(source) {
|
|
26
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
27
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.inspect_fasm(ptr0, len0);
|
|
29
|
+
if (ret[2]) {
|
|
30
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
31
|
+
}
|
|
32
|
+
return takeFromExternrefTable0(ret[0]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Validates .fasm source and returns UTF-16 line/column diagnostics for Monaco/CodeMirror.
|
|
37
|
+
* @param {string} source
|
|
38
|
+
* @returns {IdeDiagnostic[]}
|
|
39
|
+
*/
|
|
40
|
+
export function validate_fasm(source) {
|
|
41
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
42
|
+
const len0 = WASM_VECTOR_LEN;
|
|
43
|
+
const ret = wasm.validate_fasm(ptr0, len0);
|
|
44
|
+
if (ret[2]) {
|
|
45
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
46
|
+
}
|
|
47
|
+
return takeFromExternrefTable0(ret[0]);
|
|
48
|
+
}
|
|
49
|
+
function __wbg_get_imports() {
|
|
50
|
+
const import0 = {
|
|
51
|
+
__proto__: null,
|
|
52
|
+
__wbg_Error_208446807d0d1e30: function(arg0, arg1) {
|
|
53
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
54
|
+
return ret;
|
|
55
|
+
},
|
|
56
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
57
|
+
const ret = String(arg1);
|
|
58
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len1 = WASM_VECTOR_LEN;
|
|
60
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
|
|
61
|
+
getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
|
|
62
|
+
},
|
|
63
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
64
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
65
|
+
},
|
|
66
|
+
__wbg_new_37eb45aaf5eeb820: function() {
|
|
67
|
+
const ret = new Array();
|
|
68
|
+
return ret;
|
|
69
|
+
},
|
|
70
|
+
__wbg_new_cd4348290afae586: function() {
|
|
71
|
+
const ret = new Object();
|
|
72
|
+
return ret;
|
|
73
|
+
},
|
|
74
|
+
__wbg_set_d2d33b52458e984a: function(arg0, arg1, arg2) {
|
|
75
|
+
arg0[arg1 >>> 0] = arg2;
|
|
76
|
+
},
|
|
77
|
+
__wbg_set_e4b9a833d288759a: function(arg0, arg1, arg2) {
|
|
78
|
+
arg0[arg1] = arg2;
|
|
79
|
+
},
|
|
80
|
+
__wbindgen_generic_0000000000000001: function(arg0) {
|
|
81
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
82
|
+
const ret = arg0;
|
|
83
|
+
return ret;
|
|
84
|
+
},
|
|
85
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
86
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
87
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
88
|
+
return ret;
|
|
89
|
+
},
|
|
90
|
+
__wbindgen_generic_0000000000000003: function(arg0) {
|
|
91
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
92
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
93
|
+
return ret;
|
|
94
|
+
},
|
|
95
|
+
__wbindgen_init_externref_table: function() {
|
|
96
|
+
const table = wasm.__wbindgen_externrefs;
|
|
97
|
+
table.set(0, undefined);
|
|
98
|
+
table.set(1024, undefined);
|
|
99
|
+
table.set(1025, null);
|
|
100
|
+
table.set(1026, true);
|
|
101
|
+
table.set(1027, false);
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
return {
|
|
105
|
+
__proto__: null,
|
|
106
|
+
"./frameassembly_wasm_bg.js": import0,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
111
|
+
ptr = ptr >>> 0;
|
|
112
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let cachedDataViewMemory0 = null;
|
|
116
|
+
function getDataViewMemory0() {
|
|
117
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
118
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
119
|
+
}
|
|
120
|
+
return cachedDataViewMemory0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getStringFromWasm0(ptr, len) {
|
|
124
|
+
ptr = ptr >>> 0;
|
|
125
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let cachedUint8ArrayMemory0 = null;
|
|
129
|
+
function getUint8ArrayMemory0() {
|
|
130
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
131
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
132
|
+
}
|
|
133
|
+
return cachedUint8ArrayMemory0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
137
|
+
if (realloc === undefined) {
|
|
138
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
139
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
140
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
141
|
+
WASM_VECTOR_LEN = buf.length;
|
|
142
|
+
return ptr;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let len = arg.length;
|
|
146
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
147
|
+
|
|
148
|
+
const mem = getUint8ArrayMemory0();
|
|
149
|
+
|
|
150
|
+
let offset = 0;
|
|
151
|
+
|
|
152
|
+
for (; offset < len; offset++) {
|
|
153
|
+
const code = arg.charCodeAt(offset);
|
|
154
|
+
if (code > 0x7F) break;
|
|
155
|
+
mem[ptr + offset] = code;
|
|
156
|
+
}
|
|
157
|
+
if (offset !== len) {
|
|
158
|
+
if (offset !== 0) {
|
|
159
|
+
arg = arg.slice(offset);
|
|
160
|
+
}
|
|
161
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
162
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
163
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
164
|
+
|
|
165
|
+
offset += ret.written;
|
|
166
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
WASM_VECTOR_LEN = offset;
|
|
170
|
+
return ptr;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function takeFromExternrefTable0(idx) {
|
|
174
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
175
|
+
wasm.__externref_table_dealloc(idx);
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
180
|
+
cachedTextDecoder.decode();
|
|
181
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
182
|
+
let numBytesDecoded = 0;
|
|
183
|
+
function decodeText(bytes) {
|
|
184
|
+
numBytesDecoded += bytes.length;
|
|
185
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
186
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
187
|
+
cachedTextDecoder.decode();
|
|
188
|
+
numBytesDecoded = bytes.length;
|
|
189
|
+
}
|
|
190
|
+
return cachedTextDecoder.decode(bytes);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const cachedTextEncoder = new TextEncoder();
|
|
194
|
+
|
|
195
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
196
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
197
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
198
|
+
view.set(buf);
|
|
199
|
+
return {
|
|
200
|
+
read: arg.length,
|
|
201
|
+
written: buf.length
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
let WASM_VECTOR_LEN = 0;
|
|
207
|
+
|
|
208
|
+
let wasmModule, wasmInstance, wasm;
|
|
209
|
+
function __wbg_finalize_init(instance, module) {
|
|
210
|
+
wasmInstance = instance;
|
|
211
|
+
wasm = instance.exports;
|
|
212
|
+
wasmModule = module;
|
|
213
|
+
cachedDataViewMemory0 = null;
|
|
214
|
+
cachedUint8ArrayMemory0 = null;
|
|
215
|
+
wasm.__wbindgen_start();
|
|
216
|
+
return wasm;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function __wbg_load(module, imports) {
|
|
220
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
221
|
+
if (!module.ok) {
|
|
222
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
226
|
+
try {
|
|
227
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
228
|
+
} catch (e) {
|
|
229
|
+
const validResponse = expectedResponseType(module.type);
|
|
230
|
+
|
|
231
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
232
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
233
|
+
|
|
234
|
+
} else { throw e; }
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const bytes = await module.arrayBuffer();
|
|
239
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
240
|
+
} else {
|
|
241
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
242
|
+
|
|
243
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
244
|
+
return { instance, module };
|
|
245
|
+
} else {
|
|
246
|
+
return instance;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function expectedResponseType(type) {
|
|
251
|
+
switch (type) {
|
|
252
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
253
|
+
}
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function initSync(module) {
|
|
259
|
+
if (wasm !== undefined) return wasm;
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if (module !== undefined) {
|
|
263
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
264
|
+
({module} = module)
|
|
265
|
+
} else {
|
|
266
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const imports = __wbg_get_imports();
|
|
271
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
272
|
+
module = new WebAssembly.Module(module);
|
|
273
|
+
}
|
|
274
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
275
|
+
return __wbg_finalize_init(instance, module);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
let __wbg_init_promise;
|
|
279
|
+
async function __wbg_init(module_or_path) {
|
|
280
|
+
if (wasm !== undefined) return wasm;
|
|
281
|
+
if (__wbg_init_promise === undefined) {
|
|
282
|
+
__wbg_init_promise = __wbg_init_once(module_or_path);
|
|
283
|
+
__wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
|
|
284
|
+
}
|
|
285
|
+
return __wbg_init_promise;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function __wbg_init_once(module_or_path) {
|
|
289
|
+
|
|
290
|
+
if (module_or_path !== undefined) {
|
|
291
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
292
|
+
({module_or_path} = module_or_path)
|
|
293
|
+
} else {
|
|
294
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (module_or_path === undefined) {
|
|
299
|
+
module_or_path = new URL('frameassembly_wasm_bg.wasm', import.meta.url);
|
|
300
|
+
}
|
|
301
|
+
const imports = __wbg_get_imports();
|
|
302
|
+
|
|
303
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
304
|
+
module_or_path = fetch(module_or_path);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
308
|
+
|
|
309
|
+
return __wbg_finalize_init(instance, module);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frameassembly-wasm",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Steve Winschel"
|
|
6
|
+
],
|
|
7
|
+
"description": "WebAssembly compiler, packet inspector, and IDE diagnostics for the FrameAssembly (.fasm) network packet synthesis DSL",
|
|
8
|
+
"version": "1.4.1",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/SteveWinschel/FrameAssembly"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"frameassembly_wasm_bg.wasm",
|
|
16
|
+
"frameassembly_wasm.js",
|
|
17
|
+
"frameassembly_wasm.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "frameassembly_wasm.js",
|
|
20
|
+
"homepage": "https://github.com/SteveWinschel/FrameAssembly",
|
|
21
|
+
"types": "frameassembly_wasm.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./snippets/*"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"frameassembly",
|
|
27
|
+
"pcap",
|
|
28
|
+
"pcapng",
|
|
29
|
+
"wireshark",
|
|
30
|
+
"wasm"
|
|
31
|
+
]
|
|
32
|
+
}
|