frameassembly-wasm 0.0.0-stage → 1.2.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 +64 -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,65 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frameassembly-wasm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
WebAssembly compiler, frame inspector, and UTF-16 IDE diagnostics for **FrameAssembly (`.fasm`)** — a deterministic domain-specific language for synthesizing standards-compliant network packets (L2–L7) and PCAPNG captures. *(Note: FrameAssembly is a network protocol DSL, not x86 Flat Assembler).*
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install frameassembly-wasm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Initialization (Vite / React / Google AI Studio)
|
|
12
|
+
|
|
13
|
+
Import the WebAssembly binary URL explicitly with `?url` so Vite serves the `.wasm` asset cleanly in both dev and production builds:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import init, {
|
|
17
|
+
validate_fasm,
|
|
18
|
+
inspect_fasm,
|
|
19
|
+
compile_fasm_to_pcapng,
|
|
20
|
+
type IdeDiagnostic,
|
|
21
|
+
type PacketPreview,
|
|
22
|
+
} from "frameassembly-wasm";
|
|
23
|
+
import wasmUrl from "frameassembly-wasm/frameassembly_wasm_bg.wasm?url";
|
|
24
|
+
|
|
25
|
+
// Call once at app startup (idempotent)
|
|
26
|
+
await init({ module_or_path: wasmUrl });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Browser CDN Usage (No Bundler)
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import init, {
|
|
33
|
+
validate_fasm,
|
|
34
|
+
inspect_fasm,
|
|
35
|
+
compile_fasm_to_pcapng,
|
|
36
|
+
} from "[https://cdn.jsdelivr.net/npm/frameassembly-wasm@1.2.1/frameassembly_wasm.js](https://cdn.jsdelivr.net/npm/frameassembly-wasm@1.2.1/frameassembly_wasm.js)";
|
|
37
|
+
|
|
38
|
+
await init();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API Reference
|
|
42
|
+
|
|
43
|
+
- `validate_fasm(source: string): IdeDiagnostic[]` — Parses and compiles `.fasm` source, returning zero-based UTF-16 line/column spans (`start_line`, `start_col`, `end_line`, `end_col`, `message`, `help?`) ready for Monaco or CodeMirror markers. Returns `[]` when valid.
|
|
44
|
+
- `inspect_fasm(source: string): PacketPreview[]` — Compiles `.fasm` source and returns frame previews (`index`, zero-based `timestamp_ms`, byte `length`, space-separated lowercase `hex`). Throws `Error` if source is invalid.
|
|
45
|
+
- `compile_fasm_to_pcapng(source: string): Uint8Array` — Compiles `.fasm` source into a Wireshark-ready PCAPNG byte array with nanosecond resolution. Throws `Error` if source is invalid.
|
|
46
|
+
|
|
47
|
+
## Minimal `.fasm` Example & PCAPNG Download
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const source = `HOST client = 00:11:22:33:44:55 / 192.168.1.10
|
|
51
|
+
HOST server = aa:bb:cc:dd:ee:ff / 192.168.1.20
|
|
52
|
+
|
|
53
|
+
client -> server : TCP SYN DSTPORT=443
|
|
54
|
+
server -> client : TCP SYN ACK SRCPORT=443
|
|
55
|
+
client -> server : TCP ACK DSTPORT=443`;
|
|
56
|
+
|
|
57
|
+
const diagnostics = validate_fasm(source);
|
|
58
|
+
if (diagnostics.length === 0) {
|
|
59
|
+
const frames = inspect_fasm(source);
|
|
60
|
+
const pcapngBytes = compile_fasm_to_pcapng(source);
|
|
61
|
+
const blob = new Blob([pcapngBytes], { type: "application/vnd.tcpdump.pcap" });
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Full grammar and protocol reference: https://github.com/SteveWinschel/FrameAssembly/blob/main/llms.txt
|
|
@@ -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.2.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
|
+
}
|