@goodtools/wiregasm 1.0.0 → 1.2.0
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/dist/main.js +63 -8
- package/dist/main.js.map +1 -1
- package/dist/module.js +49 -9
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +230 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/wiregasm.data.gz +0 -0
- package/dist/wiregasm.wasm.gz +0 -0
- package/package.json +4 -2
package/dist/main.js
CHANGED
|
@@ -1,34 +1,85 @@
|
|
|
1
|
+
function $parcel$exportWildcard(dest, source) {
|
|
2
|
+
Object.keys(source).forEach(function(key) {
|
|
3
|
+
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(dest, key, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return source[key];
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return dest;
|
|
16
|
+
}
|
|
1
17
|
function $parcel$export(e, n, v, s) {
|
|
2
18
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
3
19
|
}
|
|
4
20
|
|
|
5
21
|
$parcel$export(module.exports, "Wiregasm", () => $882b6d93070905b3$export$c4e6ddb7806910b1);
|
|
22
|
+
var $9ba0f9a5c47c04f2$exports = {};
|
|
23
|
+
|
|
24
|
+
$parcel$export($9ba0f9a5c47c04f2$exports, "vectorToArray", () => $9ba0f9a5c47c04f2$export$4b978bcb0889dc66);
|
|
25
|
+
function $9ba0f9a5c47c04f2$export$4b978bcb0889dc66(vec) {
|
|
26
|
+
return new Array(vec.size()).fill(0).map((_, id)=>vec.get(id));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var $faefaad95e5fcca0$exports = {};
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
class $882b6d93070905b3$export$c4e6ddb7806910b1 {
|
|
7
35
|
constructor(){
|
|
8
36
|
this.initialized = false;
|
|
9
37
|
this.session = null;
|
|
10
38
|
}
|
|
11
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Initialize the wrapper and the Wiregasm module
|
|
41
|
+
*
|
|
42
|
+
* @param loader Loader function for the Emscripten module
|
|
43
|
+
* @param overrides Overrides
|
|
44
|
+
*/ async init(loader, overrides = {}) {
|
|
12
45
|
if (this.initialized) return;
|
|
13
|
-
this.initialized = true;
|
|
14
46
|
this.lib = await loader(overrides);
|
|
15
47
|
this.uploadDir = this.lib.getUploadDirectory();
|
|
16
48
|
this.lib.init();
|
|
49
|
+
this.initialized = true;
|
|
17
50
|
}
|
|
18
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Check the validity of a filter expression.
|
|
53
|
+
*
|
|
54
|
+
* @param filter A display filter expression
|
|
55
|
+
*/ test_filter(filter) {
|
|
19
56
|
return this.lib.checkFilter(filter);
|
|
20
57
|
}
|
|
21
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Load a packet trace file for analysis.
|
|
60
|
+
*
|
|
61
|
+
* @returns Response containing the status and summary
|
|
62
|
+
*/ load(name, data, opts = {}) {
|
|
22
63
|
if (this.session != null) this.session.delete();
|
|
23
64
|
const path = this.uploadDir + "/" + name;
|
|
24
65
|
this.lib.FS.writeFile(path, data, opts);
|
|
25
66
|
this.session = new this.lib.DissectSession(path);
|
|
26
67
|
return this.session.load();
|
|
27
68
|
}
|
|
28
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Get Packet List information for a range of packets.
|
|
71
|
+
*
|
|
72
|
+
* @param filter Output those frames that pass this filter expression
|
|
73
|
+
* @param skip Skip N frames
|
|
74
|
+
* @param limit Limit the output to N frames
|
|
75
|
+
*/ frames(filter, skip = 0, limit = 0) {
|
|
29
76
|
return this.session.getFrames(filter, skip, limit);
|
|
30
77
|
}
|
|
31
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Get full information about a frame including the protocol tree.
|
|
80
|
+
*
|
|
81
|
+
* @param number Frame number
|
|
82
|
+
*/ frame(num) {
|
|
32
83
|
return this.session.getFrame(num);
|
|
33
84
|
}
|
|
34
85
|
destroy() {
|
|
@@ -41,12 +92,16 @@ class $882b6d93070905b3$export$c4e6ddb7806910b1 {
|
|
|
41
92
|
this.initialized = false;
|
|
42
93
|
}
|
|
43
94
|
}
|
|
44
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Returns the column headers
|
|
97
|
+
*/ columns() {
|
|
45
98
|
const vec = this.lib.getColumns();
|
|
46
99
|
// convert it from a vector to array
|
|
47
|
-
return
|
|
100
|
+
return (0, $9ba0f9a5c47c04f2$export$4b978bcb0889dc66)(vec);
|
|
48
101
|
}
|
|
49
102
|
}
|
|
103
|
+
$parcel$exportWildcard(module.exports, $9ba0f9a5c47c04f2$exports);
|
|
104
|
+
$parcel$exportWildcard(module.exports, $faefaad95e5fcca0$exports);
|
|
50
105
|
|
|
51
106
|
|
|
52
107
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;ACQO,SAAS,0CAAiB,GAAc,EAAO;IACpD,OAAO,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,KAAO,IAAI,GAAG,CAAC;AAC9D;;ADVA;;;;;AAeO,MAAM;IAMX,aAAc;QACZ,IAAI,CAAC,WAAW,GAAG,KAAK;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI;IACrB;IAEA;;;;;GAKC,GACD,MAAM,KAAK,MAAsB,EAAE,YAAkC,CAAC,CAAC,EAAE;QACvE,IAAI,IAAI,CAAC,WAAW,EAClB;QAGF,IAAI,CAAC,GAAG,GAAG,MAAM,OAAO;QACxB,IAAI,CAAC,SAAS,GAAG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,EAAE;IACvB;AACF","sources":["src/index.ts","src/utils.ts","src/types.ts"],"sourcesContent":["import {\n CheckFilterResponse,\n DissectSession,\n Frame,\n FramesResponse,\n LoadResponse,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n} from \"./types\";\nimport { vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(loader: WiregasmLoader, overrides: WiregasmLibOverrides = {}) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.lib.init();\n this.initialized = true;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n","import { Vector } from \"./types\";\n\n/**\n * Converts a Vector to a JS array\n *\n * @param vec Vector\n * @returns JS array of the Vector contents\n */\nexport function vectorToArray<T>(vec: Vector<T>): T[] {\n return new Array(vec.size()).fill(0).map((_, id) => vec.get(id));\n}\n","export interface EmscriptenFileSystem {\n writeFile(\n path: string,\n data: string | ArrayBufferView,\n opts?: { flags?: string | undefined }\n ): void;\n readdir(path: string): string[];\n}\n\nexport interface EmscriptenHeap {\n buffer: ArrayBufferLike;\n}\n\nexport interface EmscriptenModule {\n FS: EmscriptenFileSystem;\n HEAPU8: EmscriptenHeap;\n _malloc(size: number): number;\n}\n\nexport interface Vector<T> {\n size(): number;\n get(index: number): T;\n}\n\nexport interface DataSource {\n name: string;\n data: string;\n}\n\nexport interface ProtoTree {\n label: string;\n filter: string;\n start: number;\n length: number;\n data_source_idx: number;\n tree: Vector<ProtoTree>;\n}\n\nexport interface Frame {\n number: number;\n comments: Vector<string>;\n data_sources: Vector<DataSource>;\n tree: Vector<ProtoTree>;\n}\n\nexport interface FramesResponse {\n frames: Vector<FrameMeta>;\n matched: number;\n}\n\nexport interface FrameMeta {\n number: number;\n comments: boolean;\n ignored: boolean;\n marked: boolean;\n bg: number;\n fg: number;\n columns: Vector<string>;\n}\n\nexport interface LoadSummary {\n filename: string;\n file_type: string;\n file_length: number;\n file_encap_type: string;\n packet_count: number;\n start_time: number;\n stop_time: number;\n elapsed_time: number;\n}\n\nexport interface LoadResponse {\n code: number;\n error: string;\n summary: LoadSummary;\n}\n\nexport interface DissectSession {\n /**\n * Free up any memory used by the session\n */\n delete(): void;\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(): LoadResponse;\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n getFrames(filter: string, skip: number, limit: number): FramesResponse;\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n getFrame(number: number): Frame;\n}\n\nexport interface DissectSessionConstructable {\n new (path: string): DissectSession;\n}\n\nexport interface CheckFilterResponse {\n ok: boolean;\n error: string;\n}\n\nexport interface WiregasmLibOverrides {\n /**\n * If set, this method will be called when the runtime needs to load a file,\n * such as a .wasm WebAssembly file, .mem memory init file, or a file generated\n * by the file packager. The function receives the relative path to the file as\n * configured in build process and a prefix (path to the main JavaScript file’s\n * directory), and should return the actual URL.\n *\n * This lets you host file packages or the .mem file etc. on a different location\n * than the directory of the JavaScript file (which is the default expectation),\n * for example if you want to host them on a CDN.\n *\n * @param path Path of the requested file.\n * @param prefix Prefix of the requested path. May be empty.\n *\n * @returns Path to the requested file.\n */\n locateFile?(path: string, prefix: string): string;\n\n /**\n * Called when something is printed to standard error (stderr)\n *\n * @param error Error content\n */\n printErr?(error: string): void;\n\n /**\n * Called when something is printed to standard output (stdout)\n *\n * @param message Message content\n */\n print?(message: string): void;\n\n /**\n * Called from within the Wiregasm Library to notify\n * about any status updates.\n *\n * @param type Type of the status\n * @param message Message content\n */\n handleStatus?(type: number, message: string): void;\n\n /**\n * If you can fetch the binary yourself, you can set it\n */\n wasmBinary?: ArrayBuffer;\n\n /**\n * If you want to manually manage the download of .data file packages for\n * custom caching, progress reporting and error handling behavior,\n * you can implement this override.\n */\n getPreloadedPackage?(name: string, size: number): ArrayBuffer;\n}\n\nexport interface WiregasmLib extends EmscriptenModule {\n DissectSession: DissectSessionConstructable;\n\n /**\n * Returns the directory where files are uploaded\n *\n * @returns Path of the directory\n */\n getUploadDirectory(): string;\n\n /**\n * Initialize the library, load preferences and register dissectors\n */\n init(): boolean;\n\n /**\n * Clean up any memory associated with the lib\n */\n destroy(): void;\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n checkFilter(filter: string): CheckFilterResponse;\n\n /**\n * Returns the column headers\n */\n getColumns(): Vector<string>;\n\n /**\n * Creates a new file in the upload directory with the supplied data\n *\n * @param file_name Name of the file\n * @param data_ptr Pointer to the data\n * @param length Length of the data\n */\n upload(file_name: string, data_ptr: number, length: number): string;\n}\n\nexport type WiregasmLoader = (\n overrides: WiregasmLibOverrides\n) => Promise<WiregasmLib>;\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,29 +1,67 @@
|
|
|
1
|
+
function $parcel$export(e, n, v, s) {
|
|
2
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
3
|
+
}
|
|
4
|
+
var $fab42eb3dee39b5b$exports = {};
|
|
5
|
+
|
|
6
|
+
$parcel$export($fab42eb3dee39b5b$exports, "vectorToArray", () => $fab42eb3dee39b5b$export$4b978bcb0889dc66);
|
|
7
|
+
function $fab42eb3dee39b5b$export$4b978bcb0889dc66(vec) {
|
|
8
|
+
return new Array(vec.size()).fill(0).map((_, id)=>vec.get(id));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var $81c1b644006d48ec$exports = {};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
1
16
|
class $149c1bd638913645$export$c4e6ddb7806910b1 {
|
|
2
17
|
constructor(){
|
|
3
18
|
this.initialized = false;
|
|
4
19
|
this.session = null;
|
|
5
20
|
}
|
|
6
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Initialize the wrapper and the Wiregasm module
|
|
23
|
+
*
|
|
24
|
+
* @param loader Loader function for the Emscripten module
|
|
25
|
+
* @param overrides Overrides
|
|
26
|
+
*/ async init(loader, overrides = {}) {
|
|
7
27
|
if (this.initialized) return;
|
|
8
|
-
this.initialized = true;
|
|
9
28
|
this.lib = await loader(overrides);
|
|
10
29
|
this.uploadDir = this.lib.getUploadDirectory();
|
|
11
30
|
this.lib.init();
|
|
31
|
+
this.initialized = true;
|
|
12
32
|
}
|
|
13
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Check the validity of a filter expression.
|
|
35
|
+
*
|
|
36
|
+
* @param filter A display filter expression
|
|
37
|
+
*/ test_filter(filter) {
|
|
14
38
|
return this.lib.checkFilter(filter);
|
|
15
39
|
}
|
|
16
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Load a packet trace file for analysis.
|
|
42
|
+
*
|
|
43
|
+
* @returns Response containing the status and summary
|
|
44
|
+
*/ load(name, data, opts = {}) {
|
|
17
45
|
if (this.session != null) this.session.delete();
|
|
18
46
|
const path = this.uploadDir + "/" + name;
|
|
19
47
|
this.lib.FS.writeFile(path, data, opts);
|
|
20
48
|
this.session = new this.lib.DissectSession(path);
|
|
21
49
|
return this.session.load();
|
|
22
50
|
}
|
|
23
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Get Packet List information for a range of packets.
|
|
53
|
+
*
|
|
54
|
+
* @param filter Output those frames that pass this filter expression
|
|
55
|
+
* @param skip Skip N frames
|
|
56
|
+
* @param limit Limit the output to N frames
|
|
57
|
+
*/ frames(filter, skip = 0, limit = 0) {
|
|
24
58
|
return this.session.getFrames(filter, skip, limit);
|
|
25
59
|
}
|
|
26
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Get full information about a frame including the protocol tree.
|
|
62
|
+
*
|
|
63
|
+
* @param number Frame number
|
|
64
|
+
*/ frame(num) {
|
|
27
65
|
return this.session.getFrame(num);
|
|
28
66
|
}
|
|
29
67
|
destroy() {
|
|
@@ -36,13 +74,15 @@ class $149c1bd638913645$export$c4e6ddb7806910b1 {
|
|
|
36
74
|
this.initialized = false;
|
|
37
75
|
}
|
|
38
76
|
}
|
|
39
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Returns the column headers
|
|
79
|
+
*/ columns() {
|
|
40
80
|
const vec = this.lib.getColumns();
|
|
41
81
|
// convert it from a vector to array
|
|
42
|
-
return
|
|
82
|
+
return (0, $fab42eb3dee39b5b$export$4b978bcb0889dc66)(vec);
|
|
43
83
|
}
|
|
44
84
|
}
|
|
45
85
|
|
|
46
86
|
|
|
47
|
-
export {$149c1bd638913645$export$c4e6ddb7806910b1 as Wiregasm};
|
|
87
|
+
export {$149c1bd638913645$export$c4e6ddb7806910b1 as Wiregasm, $fab42eb3dee39b5b$export$4b978bcb0889dc66 as vectorToArray};
|
|
48
88
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;ACQO,SAAS,0CAAiB,GAAc,EAAO;IACpD,OAAO,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,KAAO,IAAI,GAAG,CAAC;AAC9D;;ADVA;;;;;AAeO,MAAM;IAMX,aAAc;QACZ,IAAI,CAAC,WAAW,GAAG,KAAK;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI;IACrB;IAEA;;;;;GAKC,GACD,MAAM,KAAK,MAAsB,EAAE,YAAkC,CAAC,CAAC,EAAE;QACvE,IAAI,IAAI,CAAC,WAAW,EAClB;QAGF,IAAI,CAAC,GAAG,GAAG,MAAM,OAAO;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB;QAC5C,IAAI,CAAC,GAAG,CAAC,IAAI;QACb,IAAI,CAAC,WAAW,GAAG,IAAI;IACzB;IAEA;;;;GAIC,GACD,YAAY,MAAc,EAAuB;QAC/C,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;IAC9B;IAEA;;;;GAIC,GACD,KACE,IAAY,EACZ,IAA8B,EAC9B,OAAe,CAAC,CAAC,EACH;QACd,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EACtB,IAAI,CAAC,OAAO,CAAC,MAAM;QAGrB,MAAM,OAAO,IAAI,CAAC,SAAS,GAAG,MAAM;QACpC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,MAAM;QAElC,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;QAE3C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI;IAC1B;IAEA;;;;;;GAMC,GACD,OAAO,MAAc,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,EAAkB;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,MAAM;IAC9C;IAEA;;;;GAIC,GACD,MAAM,GAAW,EAAS;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B;IAEA,UAAU;QACR,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;gBACzB,IAAI,CAAC,OAAO,CAAC,MAAM;gBACnB,IAAI,CAAC,OAAO,GAAG,IAAI;YACrB,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,OAAO;YAChB,IAAI,CAAC,WAAW,GAAG,KAAK;QAC1B,CAAC;IACH;IAEA;;GAEC,GACD,UAAoB;QAClB,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU;QAE/B,oCAAoC;QACpC,OAAO,CAAA,GAAA,yCAAY,EAAE;IACvB;AACF","sources":["src/index.ts","src/utils.ts","src/types.ts"],"sourcesContent":["import {\n CheckFilterResponse,\n DissectSession,\n Frame,\n FramesResponse,\n LoadResponse,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n} from \"./types\";\nimport { vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(loader: WiregasmLoader, overrides: WiregasmLibOverrides = {}) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.lib.init();\n this.initialized = true;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n","import { Vector } from \"./types\";\n\n/**\n * Converts a Vector to a JS array\n *\n * @param vec Vector\n * @returns JS array of the Vector contents\n */\nexport function vectorToArray<T>(vec: Vector<T>): T[] {\n return new Array(vec.size()).fill(0).map((_, id) => vec.get(id));\n}\n","export interface EmscriptenFileSystem {\n writeFile(\n path: string,\n data: string | ArrayBufferView,\n opts?: { flags?: string | undefined }\n ): void;\n readdir(path: string): string[];\n}\n\nexport interface EmscriptenHeap {\n buffer: ArrayBufferLike;\n}\n\nexport interface EmscriptenModule {\n FS: EmscriptenFileSystem;\n HEAPU8: EmscriptenHeap;\n _malloc(size: number): number;\n}\n\nexport interface Vector<T> {\n size(): number;\n get(index: number): T;\n}\n\nexport interface DataSource {\n name: string;\n data: string;\n}\n\nexport interface ProtoTree {\n label: string;\n filter: string;\n start: number;\n length: number;\n data_source_idx: number;\n tree: Vector<ProtoTree>;\n}\n\nexport interface Frame {\n number: number;\n comments: Vector<string>;\n data_sources: Vector<DataSource>;\n tree: Vector<ProtoTree>;\n}\n\nexport interface FramesResponse {\n frames: Vector<FrameMeta>;\n matched: number;\n}\n\nexport interface FrameMeta {\n number: number;\n comments: boolean;\n ignored: boolean;\n marked: boolean;\n bg: number;\n fg: number;\n columns: Vector<string>;\n}\n\nexport interface LoadSummary {\n filename: string;\n file_type: string;\n file_length: number;\n file_encap_type: string;\n packet_count: number;\n start_time: number;\n stop_time: number;\n elapsed_time: number;\n}\n\nexport interface LoadResponse {\n code: number;\n error: string;\n summary: LoadSummary;\n}\n\nexport interface DissectSession {\n /**\n * Free up any memory used by the session\n */\n delete(): void;\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(): LoadResponse;\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n getFrames(filter: string, skip: number, limit: number): FramesResponse;\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n getFrame(number: number): Frame;\n}\n\nexport interface DissectSessionConstructable {\n new (path: string): DissectSession;\n}\n\nexport interface CheckFilterResponse {\n ok: boolean;\n error: string;\n}\n\nexport interface WiregasmLibOverrides {\n /**\n * If set, this method will be called when the runtime needs to load a file,\n * such as a .wasm WebAssembly file, .mem memory init file, or a file generated\n * by the file packager. The function receives the relative path to the file as\n * configured in build process and a prefix (path to the main JavaScript file’s\n * directory), and should return the actual URL.\n *\n * This lets you host file packages or the .mem file etc. on a different location\n * than the directory of the JavaScript file (which is the default expectation),\n * for example if you want to host them on a CDN.\n *\n * @param path Path of the requested file.\n * @param prefix Prefix of the requested path. May be empty.\n *\n * @returns Path to the requested file.\n */\n locateFile?(path: string, prefix: string): string;\n\n /**\n * Called when something is printed to standard error (stderr)\n *\n * @param error Error content\n */\n printErr?(error: string): void;\n\n /**\n * Called when something is printed to standard output (stdout)\n *\n * @param message Message content\n */\n print?(message: string): void;\n\n /**\n * Called from within the Wiregasm Library to notify\n * about any status updates.\n *\n * @param type Type of the status\n * @param message Message content\n */\n handleStatus?(type: number, message: string): void;\n\n /**\n * If you can fetch the binary yourself, you can set it\n */\n wasmBinary?: ArrayBuffer;\n\n /**\n * If you want to manually manage the download of .data file packages for\n * custom caching, progress reporting and error handling behavior,\n * you can implement this override.\n */\n getPreloadedPackage?(name: string, size: number): ArrayBuffer;\n}\n\nexport interface WiregasmLib extends EmscriptenModule {\n DissectSession: DissectSessionConstructable;\n\n /**\n * Returns the directory where files are uploaded\n *\n * @returns Path of the directory\n */\n getUploadDirectory(): string;\n\n /**\n * Initialize the library, load preferences and register dissectors\n */\n init(): boolean;\n\n /**\n * Clean up any memory associated with the lib\n */\n destroy(): void;\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n checkFilter(filter: string): CheckFilterResponse;\n\n /**\n * Returns the column headers\n */\n getColumns(): Vector<string>;\n\n /**\n * Creates a new file in the upload directory with the supplied data\n *\n * @param file_name Name of the file\n * @param data_ptr Pointer to the data\n * @param length Length of the data\n */\n upload(file_name: string, data_ptr: number, length: number): string;\n}\n\nexport type WiregasmLoader = (\n overrides: WiregasmLibOverrides\n) => Promise<WiregasmLib>;\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,238 @@
|
|
|
1
|
+
export interface EmscriptenFileSystem {
|
|
2
|
+
writeFile(path: string, data: string | ArrayBufferView, opts?: {
|
|
3
|
+
flags?: string | undefined;
|
|
4
|
+
}): void;
|
|
5
|
+
readdir(path: string): string[];
|
|
6
|
+
}
|
|
7
|
+
export interface EmscriptenHeap {
|
|
8
|
+
buffer: ArrayBufferLike;
|
|
9
|
+
}
|
|
10
|
+
export interface EmscriptenModule {
|
|
11
|
+
FS: EmscriptenFileSystem;
|
|
12
|
+
HEAPU8: EmscriptenHeap;
|
|
13
|
+
_malloc(size: number): number;
|
|
14
|
+
}
|
|
15
|
+
export interface Vector<T> {
|
|
16
|
+
size(): number;
|
|
17
|
+
get(index: number): T;
|
|
18
|
+
}
|
|
19
|
+
export interface DataSource {
|
|
20
|
+
name: string;
|
|
21
|
+
data: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ProtoTree {
|
|
24
|
+
label: string;
|
|
25
|
+
filter: string;
|
|
26
|
+
start: number;
|
|
27
|
+
length: number;
|
|
28
|
+
data_source_idx: number;
|
|
29
|
+
tree: Vector<ProtoTree>;
|
|
30
|
+
}
|
|
31
|
+
export interface Frame {
|
|
32
|
+
number: number;
|
|
33
|
+
comments: Vector<string>;
|
|
34
|
+
data_sources: Vector<DataSource>;
|
|
35
|
+
tree: Vector<ProtoTree>;
|
|
36
|
+
}
|
|
37
|
+
export interface FramesResponse {
|
|
38
|
+
frames: Vector<FrameMeta>;
|
|
39
|
+
matched: number;
|
|
40
|
+
}
|
|
41
|
+
export interface FrameMeta {
|
|
42
|
+
number: number;
|
|
43
|
+
comments: boolean;
|
|
44
|
+
ignored: boolean;
|
|
45
|
+
marked: boolean;
|
|
46
|
+
bg: number;
|
|
47
|
+
fg: number;
|
|
48
|
+
columns: Vector<string>;
|
|
49
|
+
}
|
|
50
|
+
export interface LoadSummary {
|
|
51
|
+
filename: string;
|
|
52
|
+
file_type: string;
|
|
53
|
+
file_length: number;
|
|
54
|
+
file_encap_type: string;
|
|
55
|
+
packet_count: number;
|
|
56
|
+
start_time: number;
|
|
57
|
+
stop_time: number;
|
|
58
|
+
elapsed_time: number;
|
|
59
|
+
}
|
|
60
|
+
export interface LoadResponse {
|
|
61
|
+
code: number;
|
|
62
|
+
error: string;
|
|
63
|
+
summary: LoadSummary;
|
|
64
|
+
}
|
|
65
|
+
export interface DissectSession {
|
|
66
|
+
/**
|
|
67
|
+
* Free up any memory used by the session
|
|
68
|
+
*/
|
|
69
|
+
delete(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Load a packet trace file for analysis.
|
|
72
|
+
*
|
|
73
|
+
* @returns Response containing the status and summary
|
|
74
|
+
*/
|
|
75
|
+
load(): LoadResponse;
|
|
76
|
+
/**
|
|
77
|
+
* Get Packet List information for a range of packets.
|
|
78
|
+
*
|
|
79
|
+
* @param filter Output those frames that pass this filter expression
|
|
80
|
+
* @param skip Skip N frames
|
|
81
|
+
* @param limit Limit the output to N frames
|
|
82
|
+
*/
|
|
83
|
+
getFrames(filter: string, skip: number, limit: number): FramesResponse;
|
|
84
|
+
/**
|
|
85
|
+
* Get full information about a frame including the protocol tree.
|
|
86
|
+
*
|
|
87
|
+
* @param number Frame number
|
|
88
|
+
*/
|
|
89
|
+
getFrame(number: number): Frame;
|
|
90
|
+
}
|
|
91
|
+
export interface DissectSessionConstructable {
|
|
92
|
+
new (path: string): DissectSession;
|
|
93
|
+
}
|
|
94
|
+
export interface CheckFilterResponse {
|
|
95
|
+
ok: boolean;
|
|
96
|
+
error: string;
|
|
97
|
+
}
|
|
98
|
+
export interface WiregasmLibOverrides {
|
|
99
|
+
/**
|
|
100
|
+
* If set, this method will be called when the runtime needs to load a file,
|
|
101
|
+
* such as a .wasm WebAssembly file, .mem memory init file, or a file generated
|
|
102
|
+
* by the file packager. The function receives the relative path to the file as
|
|
103
|
+
* configured in build process and a prefix (path to the main JavaScript file’s
|
|
104
|
+
* directory), and should return the actual URL.
|
|
105
|
+
*
|
|
106
|
+
* This lets you host file packages or the .mem file etc. on a different location
|
|
107
|
+
* than the directory of the JavaScript file (which is the default expectation),
|
|
108
|
+
* for example if you want to host them on a CDN.
|
|
109
|
+
*
|
|
110
|
+
* @param path Path of the requested file.
|
|
111
|
+
* @param prefix Prefix of the requested path. May be empty.
|
|
112
|
+
*
|
|
113
|
+
* @returns Path to the requested file.
|
|
114
|
+
*/
|
|
115
|
+
locateFile?(path: string, prefix: string): string;
|
|
116
|
+
/**
|
|
117
|
+
* Called when something is printed to standard error (stderr)
|
|
118
|
+
*
|
|
119
|
+
* @param error Error content
|
|
120
|
+
*/
|
|
121
|
+
printErr?(error: string): void;
|
|
122
|
+
/**
|
|
123
|
+
* Called when something is printed to standard output (stdout)
|
|
124
|
+
*
|
|
125
|
+
* @param message Message content
|
|
126
|
+
*/
|
|
127
|
+
print?(message: string): void;
|
|
128
|
+
/**
|
|
129
|
+
* Called from within the Wiregasm Library to notify
|
|
130
|
+
* about any status updates.
|
|
131
|
+
*
|
|
132
|
+
* @param type Type of the status
|
|
133
|
+
* @param message Message content
|
|
134
|
+
*/
|
|
135
|
+
handleStatus?(type: number, message: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* If you can fetch the binary yourself, you can set it
|
|
138
|
+
*/
|
|
139
|
+
wasmBinary?: ArrayBuffer;
|
|
140
|
+
/**
|
|
141
|
+
* If you want to manually manage the download of .data file packages for
|
|
142
|
+
* custom caching, progress reporting and error handling behavior,
|
|
143
|
+
* you can implement this override.
|
|
144
|
+
*/
|
|
145
|
+
getPreloadedPackage?(name: string, size: number): ArrayBuffer;
|
|
146
|
+
}
|
|
147
|
+
export interface WiregasmLib extends EmscriptenModule {
|
|
148
|
+
DissectSession: DissectSessionConstructable;
|
|
149
|
+
/**
|
|
150
|
+
* Returns the directory where files are uploaded
|
|
151
|
+
*
|
|
152
|
+
* @returns Path of the directory
|
|
153
|
+
*/
|
|
154
|
+
getUploadDirectory(): string;
|
|
155
|
+
/**
|
|
156
|
+
* Initialize the library, load preferences and register dissectors
|
|
157
|
+
*/
|
|
158
|
+
init(): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Clean up any memory associated with the lib
|
|
161
|
+
*/
|
|
162
|
+
destroy(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Check the validity of a filter expression.
|
|
165
|
+
*
|
|
166
|
+
* @param filter A display filter expression
|
|
167
|
+
*/
|
|
168
|
+
checkFilter(filter: string): CheckFilterResponse;
|
|
169
|
+
/**
|
|
170
|
+
* Returns the column headers
|
|
171
|
+
*/
|
|
172
|
+
getColumns(): Vector<string>;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a new file in the upload directory with the supplied data
|
|
175
|
+
*
|
|
176
|
+
* @param file_name Name of the file
|
|
177
|
+
* @param data_ptr Pointer to the data
|
|
178
|
+
* @param length Length of the data
|
|
179
|
+
*/
|
|
180
|
+
upload(file_name: string, data_ptr: number, length: number): string;
|
|
181
|
+
}
|
|
182
|
+
export type WiregasmLoader = (overrides: WiregasmLibOverrides) => Promise<WiregasmLib>;
|
|
183
|
+
/**
|
|
184
|
+
* Converts a Vector to a JS array
|
|
185
|
+
*
|
|
186
|
+
* @param vec Vector
|
|
187
|
+
* @returns JS array of the Vector contents
|
|
188
|
+
*/
|
|
189
|
+
export function vectorToArray<T>(vec: Vector<T>): T[];
|
|
190
|
+
/**
|
|
191
|
+
* Wraps the WiregasmLib lib functionality and manages a single DissectSession
|
|
192
|
+
*/
|
|
1
193
|
export class Wiregasm {
|
|
2
|
-
lib:
|
|
194
|
+
lib: WiregasmLib;
|
|
3
195
|
initialized: boolean;
|
|
4
|
-
session:
|
|
196
|
+
session: DissectSession | null;
|
|
5
197
|
uploadDir: string;
|
|
6
198
|
constructor();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Initialize the wrapper and the Wiregasm module
|
|
201
|
+
*
|
|
202
|
+
* @param loader Loader function for the Emscripten module
|
|
203
|
+
* @param overrides Overrides
|
|
204
|
+
*/
|
|
205
|
+
init(loader: WiregasmLoader, overrides?: WiregasmLibOverrides): Promise<void>;
|
|
206
|
+
/**
|
|
207
|
+
* Check the validity of a filter expression.
|
|
208
|
+
*
|
|
209
|
+
* @param filter A display filter expression
|
|
210
|
+
*/
|
|
211
|
+
test_filter(filter: string): CheckFilterResponse;
|
|
212
|
+
/**
|
|
213
|
+
* Load a packet trace file for analysis.
|
|
214
|
+
*
|
|
215
|
+
* @returns Response containing the status and summary
|
|
216
|
+
*/
|
|
217
|
+
load(name: string, data: string | ArrayBufferView, opts?: object): LoadResponse;
|
|
218
|
+
/**
|
|
219
|
+
* Get Packet List information for a range of packets.
|
|
220
|
+
*
|
|
221
|
+
* @param filter Output those frames that pass this filter expression
|
|
222
|
+
* @param skip Skip N frames
|
|
223
|
+
* @param limit Limit the output to N frames
|
|
224
|
+
*/
|
|
225
|
+
frames(filter: string, skip?: number, limit?: number): FramesResponse;
|
|
226
|
+
/**
|
|
227
|
+
* Get full information about a frame including the protocol tree.
|
|
228
|
+
*
|
|
229
|
+
* @param number Frame number
|
|
230
|
+
*/
|
|
231
|
+
frame(num: number): Frame;
|
|
12
232
|
destroy(): void;
|
|
233
|
+
/**
|
|
234
|
+
* Returns the column headers
|
|
235
|
+
*/
|
|
13
236
|
columns(): string[];
|
|
14
237
|
}
|
|
15
238
|
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA;IACE,
|
|
1
|
+
{"mappings":"AAAA;IACE,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GACpC,IAAI,CAAC;IACR,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACjC;AAED;IACE,MAAM,EAAE,eAAe,CAAC;CACzB;AAED;IACE,EAAE,EAAE,oBAAoB,CAAC;IACzB,MAAM,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AAED,wBAAwB,CAAC;IACvB,IAAI,IAAI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AS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACrE;AAED,6BAA6B,CAC3B,SAAS,EAAE,oBAAoB,KAC5B,OAAO,CAAC,WAAW,CAAC,CAAC;ACrN1B;;;;;GAKG;AACH,8BAA8B,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAEpD;ACED;;GAEG;AACH;IACE,GAAG,EAAE,WAAW,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;;IAOlB;;;;;OAKG;IACG,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,SAAS,GAAE,oBAAyB;IAWvE;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;IAIhD;;;;OAIG;IACH,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,eAAe,EAC9B,IAAI,GAAE,MAAW,GAChB,YAAY;IAaf;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,SAAI,EAAE,KAAK,SAAI,GAAG,cAAc;IAI3D;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK;IAIzB,OAAO;IAYP;;OAEG;IACH,OAAO,IAAI,MAAM,EAAE;CAMpB","sources":["src/src/types.ts","src/src/utils.ts","src/src/index.ts","src/index.ts"],"sourcesContent":[null,null,null,"import {\n CheckFilterResponse,\n DissectSession,\n Frame,\n FramesResponse,\n LoadResponse,\n WiregasmLib,\n WiregasmLibOverrides,\n WiregasmLoader,\n} from \"./types\";\nimport { vectorToArray } from \"./utils\";\n\n/**\n * Wraps the WiregasmLib lib functionality and manages a single DissectSession\n */\nexport class Wiregasm {\n lib: WiregasmLib;\n initialized: boolean;\n session: DissectSession | null;\n uploadDir: string;\n\n constructor() {\n this.initialized = false;\n this.session = null;\n }\n\n /**\n * Initialize the wrapper and the Wiregasm module\n *\n * @param loader Loader function for the Emscripten module\n * @param overrides Overrides\n */\n async init(loader: WiregasmLoader, overrides: WiregasmLibOverrides = {}) {\n if (this.initialized) {\n return;\n }\n\n this.lib = await loader(overrides);\n this.uploadDir = this.lib.getUploadDirectory();\n this.lib.init();\n this.initialized = true;\n }\n\n /**\n * Check the validity of a filter expression.\n *\n * @param filter A display filter expression\n */\n test_filter(filter: string): CheckFilterResponse {\n return this.lib.checkFilter(filter);\n }\n\n /**\n * Load a packet trace file for analysis.\n *\n * @returns Response containing the status and summary\n */\n load(\n name: string,\n data: string | ArrayBufferView,\n opts: object = {}\n ): LoadResponse {\n if (this.session != null) {\n this.session.delete();\n }\n\n const path = this.uploadDir + \"/\" + name;\n this.lib.FS.writeFile(path, data, opts);\n\n this.session = new this.lib.DissectSession(path);\n\n return this.session.load();\n }\n\n /**\n * Get Packet List information for a range of packets.\n *\n * @param filter Output those frames that pass this filter expression\n * @param skip Skip N frames\n * @param limit Limit the output to N frames\n */\n frames(filter: string, skip = 0, limit = 0): FramesResponse {\n return this.session.getFrames(filter, skip, limit);\n }\n\n /**\n * Get full information about a frame including the protocol tree.\n *\n * @param number Frame number\n */\n frame(num: number): Frame {\n return this.session.getFrame(num);\n }\n\n destroy() {\n if (this.initialized) {\n if (this.session !== null) {\n this.session.delete();\n this.session = null;\n }\n\n this.lib.destroy();\n this.initialized = false;\n }\n }\n\n /**\n * Returns the column headers\n */\n columns(): string[] {\n const vec = this.lib.getColumns();\n\n // convert it from a vector to array\n return vectorToArray(vec);\n }\n}\n\nexport * from \"./types\";\nexport * from \"./utils\";\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodtools/wiregasm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Packet Analyzer powered by Wireshark compiled for WebAssembly",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"build:emscripten": "docker run -it --rm -v $(pwd):/src okhalid/wiregasm-builder:latest ./build-lib.sh",
|
|
12
12
|
"build:emscripten-local": "./build-lib.sh",
|
|
13
13
|
"build": "parcel build && npm run copy-assets",
|
|
14
|
-
"copy-assets": "cp built/bin/wiregasm
|
|
14
|
+
"copy-assets": "cp built/bin/wiregasm.* dist/",
|
|
15
15
|
"lint": "eslint src/ --fix",
|
|
16
16
|
"test": "jest --coverage",
|
|
17
17
|
"fix:prettier": "prettier \"src/**/*.ts\" --write"
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
"@semantic-release/git": "^10.0.1",
|
|
36
36
|
"@types/jest": "^29.2.5",
|
|
37
37
|
"@types/node": "^18.11.18",
|
|
38
|
+
"@types/pako": "^2.0.0",
|
|
38
39
|
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
39
40
|
"@typescript-eslint/parser": "^5.48.1",
|
|
40
41
|
"eslint": "^8.31.0",
|
|
41
42
|
"eslint-config-prettier": "^8.6.0",
|
|
42
43
|
"eslint-plugin-prettier": "^4.2.1",
|
|
43
44
|
"jest": "^29.3.1",
|
|
45
|
+
"pako": "^2.1.0",
|
|
44
46
|
"parcel": "^2.8.2",
|
|
45
47
|
"prettier": "^2.8.2",
|
|
46
48
|
"ts-jest": "^29.0.3"
|