cognium-dev 4.9.20 → 4.9.21
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/cli.js +96 -65
- package/package.json +10 -7
package/dist/cli.js
CHANGED
|
@@ -113,44 +113,65 @@ function setModule(module2) {
|
|
|
113
113
|
}
|
|
114
114
|
__name(setModule, "setModule");
|
|
115
115
|
var C;
|
|
116
|
+
function newFinalizer(handler) {
|
|
117
|
+
try {
|
|
118
|
+
return new FinalizationRegistry(handler);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error("Unsupported FinalizationRegistry:", e);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
__name(newFinalizer, "newFinalizer");
|
|
125
|
+
var finalizer = newFinalizer((address) => {
|
|
126
|
+
C._ts_lookahead_iterator_delete(address);
|
|
127
|
+
});
|
|
116
128
|
var LookaheadIterator = class {
|
|
117
129
|
static {
|
|
118
130
|
__name(this, "LookaheadIterator");
|
|
119
131
|
}
|
|
120
132
|
[0] = 0;
|
|
121
133
|
language;
|
|
134
|
+
positioned = false;
|
|
122
135
|
constructor(internal, address, language) {
|
|
123
136
|
assertInternal(internal);
|
|
124
137
|
this[0] = address;
|
|
125
138
|
this.language = language;
|
|
139
|
+
finalizer?.register(this, address, this);
|
|
126
140
|
}
|
|
127
141
|
get currentTypeId() {
|
|
128
|
-
return C._ts_lookahead_iterator_current_symbol(this[0]);
|
|
142
|
+
return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
|
|
129
143
|
}
|
|
130
144
|
get currentType() {
|
|
131
|
-
|
|
145
|
+
const id = this.currentTypeId;
|
|
146
|
+
if (id === null)
|
|
147
|
+
return null;
|
|
148
|
+
return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
|
|
132
149
|
}
|
|
133
150
|
delete() {
|
|
151
|
+
finalizer?.unregister(this);
|
|
134
152
|
C._ts_lookahead_iterator_delete(this[0]);
|
|
135
153
|
this[0] = 0;
|
|
136
154
|
}
|
|
137
155
|
reset(language, stateId) {
|
|
138
156
|
if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
|
|
139
157
|
this.language = language;
|
|
158
|
+
this.positioned = false;
|
|
140
159
|
return true;
|
|
141
160
|
}
|
|
142
161
|
return false;
|
|
143
162
|
}
|
|
144
163
|
resetState(stateId) {
|
|
145
|
-
|
|
164
|
+
if (!C._ts_lookahead_iterator_reset_state(this[0], stateId))
|
|
165
|
+
return false;
|
|
166
|
+
this.positioned = false;
|
|
167
|
+
return true;
|
|
146
168
|
}
|
|
147
169
|
[Symbol.iterator]() {
|
|
148
170
|
return {
|
|
149
171
|
next: /* @__PURE__ */ __name(() => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return { done: true, value: "" };
|
|
172
|
+
this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
|
|
173
|
+
const value = this.currentType;
|
|
174
|
+
return value === null ? { done: true, value: "" } : { done: false, value };
|
|
154
175
|
}, "next")
|
|
155
176
|
};
|
|
156
177
|
}
|
|
@@ -176,6 +197,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
|
|
|
176
197
|
return result ?? "";
|
|
177
198
|
}
|
|
178
199
|
__name(getText, "getText");
|
|
200
|
+
var finalizer2 = newFinalizer((address) => {
|
|
201
|
+
C._ts_tree_delete(address);
|
|
202
|
+
});
|
|
179
203
|
var Tree = class _Tree {
|
|
180
204
|
static {
|
|
181
205
|
__name(this, "Tree");
|
|
@@ -188,12 +212,14 @@ var Tree = class _Tree {
|
|
|
188
212
|
this[0] = address;
|
|
189
213
|
this.language = language;
|
|
190
214
|
this.textCallback = textCallback;
|
|
215
|
+
finalizer2?.register(this, address, this);
|
|
191
216
|
}
|
|
192
217
|
copy() {
|
|
193
218
|
const address = C._ts_tree_copy(this[0]);
|
|
194
219
|
return new _Tree(INTERNAL, address, this.language, this.textCallback);
|
|
195
220
|
}
|
|
196
221
|
delete() {
|
|
222
|
+
finalizer2?.unregister(this);
|
|
197
223
|
C._ts_tree_delete(this[0]);
|
|
198
224
|
this[0] = 0;
|
|
199
225
|
}
|
|
@@ -249,6 +275,9 @@ var Tree = class _Tree {
|
|
|
249
275
|
return result;
|
|
250
276
|
}
|
|
251
277
|
};
|
|
278
|
+
var finalizer3 = newFinalizer((address) => {
|
|
279
|
+
C._ts_tree_cursor_delete_wasm(address);
|
|
280
|
+
});
|
|
252
281
|
var TreeCursor = class _TreeCursor {
|
|
253
282
|
static {
|
|
254
283
|
__name(this, "TreeCursor");
|
|
@@ -262,6 +291,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
262
291
|
assertInternal(internal);
|
|
263
292
|
this.tree = tree;
|
|
264
293
|
unmarshalTreeCursor(this);
|
|
294
|
+
finalizer3?.register(this, this.tree[0], this);
|
|
265
295
|
}
|
|
266
296
|
copy() {
|
|
267
297
|
const copy = new _TreeCursor(INTERNAL, this.tree);
|
|
@@ -270,6 +300,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
270
300
|
return copy;
|
|
271
301
|
}
|
|
272
302
|
delete() {
|
|
303
|
+
finalizer3?.unregister(this);
|
|
273
304
|
marshalTreeCursor(this);
|
|
274
305
|
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
275
306
|
this[0] = this[1] = this[2] = 0;
|
|
@@ -1029,16 +1060,23 @@ ${body2}`);
|
|
|
1029
1060
|
}
|
|
1030
1061
|
}
|
|
1031
1062
|
const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
|
|
1063
|
+
return _Language.loadFromWasmExports(mod, { sync: false });
|
|
1064
|
+
}
|
|
1065
|
+
static loadFromWasmExports(mod, { sync }) {
|
|
1032
1066
|
const symbolNames = Object.keys(mod);
|
|
1033
1067
|
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
|
|
1034
1068
|
if (!functionName) {
|
|
1035
1069
|
console.log(`Couldn't find language function in Wasm file. Symbols:
|
|
1036
1070
|
${JSON.stringify(symbolNames, null, 2)}`);
|
|
1037
|
-
throw new Error("
|
|
1071
|
+
throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
|
|
1038
1072
|
}
|
|
1039
1073
|
const languageAddress = mod[functionName]();
|
|
1040
1074
|
return new _Language(INTERNAL, languageAddress);
|
|
1041
1075
|
}
|
|
1076
|
+
static loadSync(wasmModule) {
|
|
1077
|
+
const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
|
|
1078
|
+
return _Language.loadFromWasmExports(mod, { sync: true });
|
|
1079
|
+
}
|
|
1042
1080
|
};
|
|
1043
1081
|
async function Module2(moduleArg = {}) {
|
|
1044
1082
|
var moduleRtn;
|
|
@@ -1558,7 +1596,7 @@ async function Module2(moduleArg = {}) {
|
|
|
1558
1596
|
newDSO("__main__", 0, wasmImports);
|
|
1559
1597
|
}
|
|
1560
1598
|
};
|
|
1561
|
-
var ___heap_base =
|
|
1599
|
+
var ___heap_base = 82240;
|
|
1562
1600
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
|
|
1563
1601
|
var getMemory = /* @__PURE__ */ __name((size) => {
|
|
1564
1602
|
if (runtimeInitialized) {
|
|
@@ -2084,12 +2122,12 @@ async function Module2(moduleArg = {}) {
|
|
|
2084
2122
|
value: "i32",
|
|
2085
2123
|
mutable: false
|
|
2086
2124
|
}, 1024);
|
|
2087
|
-
var ___stack_high =
|
|
2088
|
-
var ___stack_low =
|
|
2125
|
+
var ___stack_high = 82240;
|
|
2126
|
+
var ___stack_low = 16704;
|
|
2089
2127
|
var ___stack_pointer = new WebAssembly.Global({
|
|
2090
2128
|
value: "i32",
|
|
2091
2129
|
mutable: true
|
|
2092
|
-
},
|
|
2130
|
+
}, 82240);
|
|
2093
2131
|
var ___table_base = new WebAssembly.Global({
|
|
2094
2132
|
value: "i32",
|
|
2095
2133
|
mutable: false
|
|
@@ -2356,7 +2394,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2356
2394
|
Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
|
|
2357
2395
|
Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
|
|
2358
2396
|
var ASM_CONSTS = {};
|
|
2359
|
-
var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
|
|
2397
|
+
var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_copy, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswpunct, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
|
|
2360
2398
|
function assignWasmExports(wasmExports2) {
|
|
2361
2399
|
Module["_malloc"] = _malloc = wasmExports2["malloc"];
|
|
2362
2400
|
Module["_calloc"] = _calloc = wasmExports2["calloc"];
|
|
@@ -2390,6 +2428,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2390
2428
|
Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
|
|
2391
2429
|
Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
|
|
2392
2430
|
Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
|
|
2431
|
+
Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
|
|
2393
2432
|
Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
|
|
2394
2433
|
Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
|
|
2395
2434
|
Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
|
|
@@ -2495,6 +2534,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2495
2534
|
Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
|
|
2496
2535
|
Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
|
|
2497
2536
|
Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
|
|
2537
|
+
Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
|
|
2498
2538
|
Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
|
|
2499
2539
|
Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
|
|
2500
2540
|
Module["_memchr"] = _memchr = wasmExports2["memchr"];
|
|
@@ -2614,6 +2654,10 @@ __name(checkModule, "checkModule");
|
|
|
2614
2654
|
var TRANSFER_BUFFER;
|
|
2615
2655
|
var LANGUAGE_VERSION;
|
|
2616
2656
|
var MIN_COMPATIBLE_VERSION;
|
|
2657
|
+
var finalizer4 = newFinalizer((addresses) => {
|
|
2658
|
+
C._ts_parser_delete(addresses[0]);
|
|
2659
|
+
C._free(addresses[1]);
|
|
2660
|
+
});
|
|
2617
2661
|
var Parser = class {
|
|
2618
2662
|
static {
|
|
2619
2663
|
__name(this, "Parser");
|
|
@@ -2630,6 +2674,7 @@ var Parser = class {
|
|
|
2630
2674
|
}
|
|
2631
2675
|
constructor() {
|
|
2632
2676
|
this.initialize();
|
|
2677
|
+
finalizer4?.register(this, [this[0], this[1]], this);
|
|
2633
2678
|
}
|
|
2634
2679
|
initialize() {
|
|
2635
2680
|
if (!checkModule()) {
|
|
@@ -2640,6 +2685,7 @@ var Parser = class {
|
|
|
2640
2685
|
this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2641
2686
|
}
|
|
2642
2687
|
delete() {
|
|
2688
|
+
finalizer4?.unregister(this);
|
|
2643
2689
|
C._ts_parser_delete(this[0]);
|
|
2644
2690
|
C._free(this[1]);
|
|
2645
2691
|
this[0] = 0;
|
|
@@ -2770,6 +2816,10 @@ var QueryError = class _QueryError extends Error {
|
|
|
2770
2816
|
this.length = length;
|
|
2771
2817
|
this.name = "QueryError";
|
|
2772
2818
|
}
|
|
2819
|
+
kind;
|
|
2820
|
+
info;
|
|
2821
|
+
index;
|
|
2822
|
+
length;
|
|
2773
2823
|
static {
|
|
2774
2824
|
__name(this, "QueryError");
|
|
2775
2825
|
}
|
|
@@ -2953,6 +3003,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
|
|
|
2953
3003
|
}
|
|
2954
3004
|
}
|
|
2955
3005
|
__name(parsePattern, "parsePattern");
|
|
3006
|
+
var finalizer5 = newFinalizer((address) => {
|
|
3007
|
+
C._ts_query_delete(address);
|
|
3008
|
+
});
|
|
2956
3009
|
var Query = class {
|
|
2957
3010
|
static {
|
|
2958
3011
|
__name(this, "Query");
|
|
@@ -3052,8 +3105,10 @@ var Query = class {
|
|
|
3052
3105
|
this.assertedProperties = assertedProperties;
|
|
3053
3106
|
this.refutedProperties = refutedProperties;
|
|
3054
3107
|
this.exceededMatchLimit = false;
|
|
3108
|
+
finalizer5?.register(this, address, this);
|
|
3055
3109
|
}
|
|
3056
3110
|
delete() {
|
|
3111
|
+
finalizer5?.unregister(this);
|
|
3057
3112
|
C._ts_query_delete(this[0]);
|
|
3058
3113
|
this[0] = 0;
|
|
3059
3114
|
}
|
|
@@ -8583,7 +8638,7 @@ function buildBashCFG(tree, startId, cache) {
|
|
|
8583
8638
|
allEdges.push({ from: entryBlock.id, to: firstBlockId, type: "sequential" });
|
|
8584
8639
|
}
|
|
8585
8640
|
const exitBlock = {
|
|
8586
|
-
id: blockIdCounter
|
|
8641
|
+
id: blockIdCounter,
|
|
8587
8642
|
type: "exit",
|
|
8588
8643
|
start_line: topLevelStatements[topLevelStatements.length - 1].endPosition.row + 1,
|
|
8589
8644
|
end_line: topLevelStatements[topLevelStatements.length - 1].endPosition.row + 1
|
|
@@ -8701,7 +8756,7 @@ function buildGoCFG(tree, blockIdCounter, cache) {
|
|
|
8701
8756
|
const hasTopLevelDecls = tree.rootNode.children.some((c) => c !== null && isGoStatement(c));
|
|
8702
8757
|
if (hasTopLevelDecls) {
|
|
8703
8758
|
const block = {
|
|
8704
|
-
id: blockIdCounter
|
|
8759
|
+
id: blockIdCounter,
|
|
8705
8760
|
type: "normal",
|
|
8706
8761
|
start_line: 1,
|
|
8707
8762
|
end_line: tree.rootNode.endPosition.row + 1
|
|
@@ -9746,7 +9801,7 @@ function buildRustDFG(tree, cache) {
|
|
|
9746
9801
|
const defs = [];
|
|
9747
9802
|
const uses = [];
|
|
9748
9803
|
let defIdCounter = 1;
|
|
9749
|
-
|
|
9804
|
+
const useIdCounter = 1;
|
|
9750
9805
|
const scopeStack = [new Map];
|
|
9751
9806
|
const functions = findNodes(tree.rootNode, "function_item");
|
|
9752
9807
|
for (const func2 of functions) {
|
|
@@ -10663,7 +10718,7 @@ function parsePythonDecorator(dec) {
|
|
|
10663
10718
|
if (!fnNode)
|
|
10664
10719
|
return null;
|
|
10665
10720
|
let receiver = "";
|
|
10666
|
-
let method
|
|
10721
|
+
let method;
|
|
10667
10722
|
if (fnNode.type === "identifier") {
|
|
10668
10723
|
method = getNodeText(fnNode);
|
|
10669
10724
|
} else if (fnNode.type === "attribute") {
|
|
@@ -10733,7 +10788,7 @@ function classifyPythonDecorator(receiver, method, imp) {
|
|
|
10733
10788
|
if (receiver && PY_HTTP_ROUTE_METHODS.has(method)) {
|
|
10734
10789
|
const isRoutey = isPyRouterReceiver(receiver);
|
|
10735
10790
|
if (isRoutey) {
|
|
10736
|
-
let framework
|
|
10791
|
+
let framework;
|
|
10737
10792
|
if (imp.hasFlask)
|
|
10738
10793
|
framework = "flask";
|
|
10739
10794
|
else if (imp.hasFastApi)
|
|
@@ -19859,7 +19914,7 @@ class ConstantPropagator {
|
|
|
19859
19914
|
}
|
|
19860
19915
|
}
|
|
19861
19916
|
const startIdx = matchingIdx >= 0 ? matchingIdx : defaultIdx;
|
|
19862
|
-
for (let i2 = 0;i2 < startIdx
|
|
19917
|
+
for (let i2 = 0;i2 < startIdx; i2++) {
|
|
19863
19918
|
this.markUnreachable(caseGroups[i2]);
|
|
19864
19919
|
}
|
|
19865
19920
|
if (startIdx >= 0) {
|
|
@@ -24572,7 +24627,7 @@ class CrossFilePass {
|
|
|
24572
24627
|
const phase1Start = Date.now();
|
|
24573
24628
|
logger.debug("cross-file: phase 1/4 starting (findCrossFileTaintFlows)");
|
|
24574
24629
|
const flows = resolver.findCrossFileTaintFlows(budgetExceeded);
|
|
24575
|
-
|
|
24630
|
+
const phase1Truncated = budgetExceeded();
|
|
24576
24631
|
logger.info("cross-file: phase 1/4 done", {
|
|
24577
24632
|
flows: flows.length,
|
|
24578
24633
|
elapsedMs: Date.now() - phase1Start
|
|
@@ -28180,17 +28235,14 @@ function findPythonRegexAllowlistWrapperSanitizers(code) {
|
|
|
28180
28235
|
const argName = m[3];
|
|
28181
28236
|
let foundGuard = false;
|
|
28182
28237
|
let returnsArg = false;
|
|
28183
|
-
let blockEnd = -1;
|
|
28184
28238
|
const maxScan = Math.min(lines.length, i2 + 40);
|
|
28185
28239
|
for (let j = i2 + 1;j < maxScan; j++) {
|
|
28186
28240
|
const line = lines[j];
|
|
28187
28241
|
if (line.trim() === "")
|
|
28188
28242
|
continue;
|
|
28189
28243
|
const indent = line.length - line.trimStart().length;
|
|
28190
|
-
if (indent <= defIndent)
|
|
28191
|
-
blockEnd = j - 1;
|
|
28244
|
+
if (indent <= defIndent)
|
|
28192
28245
|
break;
|
|
28193
|
-
}
|
|
28194
28246
|
if (!foundGuard) {
|
|
28195
28247
|
const guard = new RegExp(`if\\s+not\\s+re\\.(?:fullmatch|match)\\s*\\(\\s*(${tightRegex.source})\\s*,\\s*${argName}\\s*\\)\\s*:`);
|
|
28196
28248
|
if (guard.test(line)) {
|
|
@@ -28211,8 +28263,6 @@ function findPythonRegexAllowlistWrapperSanitizers(code) {
|
|
|
28211
28263
|
returnsArg = true;
|
|
28212
28264
|
}
|
|
28213
28265
|
}
|
|
28214
|
-
if (blockEnd === -1)
|
|
28215
|
-
blockEnd = Math.min(lines.length - 1, i2 + 39);
|
|
28216
28266
|
if (!foundGuard || !returnsArg)
|
|
28217
28267
|
continue;
|
|
28218
28268
|
wrappers.push({ name: wrapperName, defLine: i2, defIndent });
|
|
@@ -31261,7 +31311,7 @@ function findRustEvalCrateCodeInjectionFindings(code, file) {
|
|
|
31261
31311
|
continue;
|
|
31262
31312
|
if (arg.length === 0)
|
|
31263
31313
|
continue;
|
|
31264
|
-
|
|
31314
|
+
const unwrapped = arg.replace(/^&\s*/, "").trim();
|
|
31265
31315
|
if (/^"[^"]*"$/.test(unwrapped))
|
|
31266
31316
|
continue;
|
|
31267
31317
|
let tainted = false;
|
|
@@ -31948,7 +31998,7 @@ function findJsLdapInjectionFindings(code, file) {
|
|
|
31948
31998
|
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
31949
31999
|
const line = lines[i2];
|
|
31950
32000
|
const fm = line.match(filterPropRe);
|
|
31951
|
-
let expr
|
|
32001
|
+
let expr;
|
|
31952
32002
|
if (fm) {
|
|
31953
32003
|
expr = fm[1].trim();
|
|
31954
32004
|
} else if (filterShorthandRe.test(line)) {
|
|
@@ -34714,7 +34764,7 @@ class SinkFilterPass {
|
|
|
34714
34764
|
if (/^-?\d+$/.test(t) || /^"(?:[^"\\]|\\.)*"$/.test(t) || /^'(?:[^'\\]|\\.)*'$/.test(t)) {
|
|
34715
34765
|
continue;
|
|
34716
34766
|
}
|
|
34717
|
-
let helperName
|
|
34767
|
+
let helperName;
|
|
34718
34768
|
const directCall = t.match(/^([A-Za-z_]\w*)\s*\(/);
|
|
34719
34769
|
if (directCall) {
|
|
34720
34770
|
helperName = directCall[1] ?? null;
|
|
@@ -40847,7 +40897,7 @@ function buildSourceCoveredRanges(codeLines, language) {
|
|
|
40847
40897
|
function buildJsCoveredRanges(codeLines) {
|
|
40848
40898
|
const ranges = [];
|
|
40849
40899
|
const tryStack = [];
|
|
40850
|
-
|
|
40900
|
+
const braceDepthAtTry = [];
|
|
40851
40901
|
let braceDepth = 0;
|
|
40852
40902
|
for (let i2 = 0;i2 < codeLines.length; i2++) {
|
|
40853
40903
|
const line = codeLines[i2];
|
|
@@ -40921,10 +40971,6 @@ class UnhandledExceptionPass {
|
|
|
40921
40971
|
coveredRanges.push(range);
|
|
40922
40972
|
}
|
|
40923
40973
|
}
|
|
40924
|
-
const catchStarts = new Set(exGraph.pairs.map((p) => p.catchBlock.start_line));
|
|
40925
|
-
for (const range of coveredRanges) {
|
|
40926
|
-
catchStarts.add(range.end + 1);
|
|
40927
|
-
}
|
|
40928
40974
|
const throwRe = language === "python" ? PYTHON_RAISE_RE : JS_THROW_RE;
|
|
40929
40975
|
const unhandled = [];
|
|
40930
40976
|
const reportedMethods = new Set;
|
|
@@ -40933,13 +40979,6 @@ class UnhandledExceptionPass {
|
|
|
40933
40979
|
if (!throwRe.test(lineText))
|
|
40934
40980
|
continue;
|
|
40935
40981
|
let inCatch = false;
|
|
40936
|
-
for (const cs of catchStarts) {
|
|
40937
|
-
if (ln >= cs) {
|
|
40938
|
-
inCatch = true;
|
|
40939
|
-
break;
|
|
40940
|
-
}
|
|
40941
|
-
}
|
|
40942
|
-
inCatch = false;
|
|
40943
40982
|
for (const pair of exGraph.pairs) {
|
|
40944
40983
|
if (ln >= pair.catchBlock.start_line) {
|
|
40945
40984
|
const mThrow = graph.methodAtLine(ln);
|
|
@@ -49738,7 +49777,7 @@ var colors = {
|
|
|
49738
49777
|
};
|
|
49739
49778
|
|
|
49740
49779
|
// src/version.ts
|
|
49741
|
-
var version = "4.9.
|
|
49780
|
+
var version = "4.9.21";
|
|
49742
49781
|
|
|
49743
49782
|
// src/formatters.ts
|
|
49744
49783
|
var LIBRARY_API_SURFACE_TAG2 = "library-api-surface:caller-responsibility";
|
|
@@ -50168,9 +50207,18 @@ function formatJSON(results, crossFileData, profileSummary) {
|
|
|
50168
50207
|
};
|
|
50169
50208
|
return JSON.stringify(output, null, 2);
|
|
50170
50209
|
}
|
|
50210
|
+
function physicalLocation(file, line) {
|
|
50211
|
+
const hasLine = Number.isInteger(line) && line >= 1;
|
|
50212
|
+
return {
|
|
50213
|
+
physicalLocation: {
|
|
50214
|
+
artifactLocation: { uri: file },
|
|
50215
|
+
...hasLine ? { region: { startLine: line } } : {}
|
|
50216
|
+
}
|
|
50217
|
+
};
|
|
50218
|
+
}
|
|
50171
50219
|
function formatSARIF(results, crossFileData, profileSummary) {
|
|
50172
50220
|
const sarif = {
|
|
50173
|
-
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/
|
|
50221
|
+
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json",
|
|
50174
50222
|
version: "2.1.0",
|
|
50175
50223
|
runs: [
|
|
50176
50224
|
{
|
|
@@ -50235,14 +50283,7 @@ function generateSarifResults(results, crossFileData) {
|
|
|
50235
50283
|
ruleId: vuln.type.replace(/\s+/g, "-").toLowerCase(),
|
|
50236
50284
|
level: vuln.severity === "critical" || vuln.severity === "high" ? "error" : "warning",
|
|
50237
50285
|
message: { text: vuln.message },
|
|
50238
|
-
locations: [
|
|
50239
|
-
{
|
|
50240
|
-
physicalLocation: {
|
|
50241
|
-
artifactLocation: { uri: result.file },
|
|
50242
|
-
region: { startLine: vuln.line }
|
|
50243
|
-
}
|
|
50244
|
-
}
|
|
50245
|
-
],
|
|
50286
|
+
locations: [physicalLocation(result.file, vuln.line)],
|
|
50246
50287
|
properties: {
|
|
50247
50288
|
cwe: vuln.cwe,
|
|
50248
50289
|
severity: vuln.severity,
|
|
@@ -50261,22 +50302,12 @@ function generateSarifResults(results, crossFileData) {
|
|
|
50261
50302
|
message: {
|
|
50262
50303
|
text: `Cross-file taint flow from ${p.source.file}:${p.source.line} to ${p.sink.file}:${p.sink.line}`
|
|
50263
50304
|
},
|
|
50264
|
-
locations: [
|
|
50265
|
-
{
|
|
50266
|
-
physicalLocation: {
|
|
50267
|
-
artifactLocation: { uri: p.sink.file },
|
|
50268
|
-
region: { startLine: p.sink.line }
|
|
50269
|
-
}
|
|
50270
|
-
}
|
|
50271
|
-
],
|
|
50305
|
+
locations: [physicalLocation(p.sink.file, p.sink.line)],
|
|
50272
50306
|
relatedLocations: [
|
|
50273
50307
|
{
|
|
50274
50308
|
id: 0,
|
|
50275
50309
|
message: { text: "taint source" },
|
|
50276
|
-
physicalLocation
|
|
50277
|
-
artifactLocation: { uri: p.source.file },
|
|
50278
|
-
region: { startLine: p.source.line }
|
|
50279
|
-
}
|
|
50310
|
+
...physicalLocation(p.source.file, p.source.line)
|
|
50280
50311
|
}
|
|
50281
50312
|
],
|
|
50282
50313
|
properties: {
|
|
@@ -50291,8 +50322,8 @@ function generateSarifResults(results, crossFileData) {
|
|
|
50291
50322
|
|
|
50292
50323
|
// src/build-info.ts
|
|
50293
50324
|
var buildInfo = {
|
|
50294
|
-
gitSha: "
|
|
50295
|
-
builtAt: "2026-09-
|
|
50325
|
+
gitSha: "1ac1389",
|
|
50326
|
+
builtAt: "2026-09-21T17:09:28.224Z"
|
|
50296
50327
|
};
|
|
50297
50328
|
|
|
50298
50329
|
// src/utils/args.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.21",
|
|
4
4
|
"description": "Static Application Security Testing CLI for detecting security vulnerabilities via taint tracking",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"test": "bun test",
|
|
15
15
|
"clean": "rm -rf dist cognium-dev cognium-dev-* *.bun-build wasm",
|
|
16
16
|
"typecheck": "tsc --noEmit",
|
|
17
|
-
"version": "node -e \"const v = require('./package.json').version; require('fs').writeFileSync('src/version.ts', '/**\\n * Version information\\n *\\n * Kept in sync with package.json via the \\`version\\` npm lifecycle script.\\n * Do not edit manually
|
|
17
|
+
"version": "node -e \"const v = require('./package.json').version; require('fs').writeFileSync('src/version.ts', '/**\\n * Version information\\n *\\n * Kept in sync with package.json via the \\`version\\` npm lifecycle script.\\n * Do not edit manually — use \\`npm version patch|minor|major\\` instead.\\n */\\nexport const version = \\x27' + v + '\\x27;\\n')\" && git add src/version.ts",
|
|
18
18
|
"dogfood": "bun run src/cli.ts scan src/ -q",
|
|
19
|
-
"prepublishOnly": "bun run build"
|
|
19
|
+
"prepublishOnly": "bun run build",
|
|
20
|
+
"test:coverage": "bun test --coverage"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
22
23
|
"security",
|
|
@@ -66,11 +67,13 @@
|
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
69
|
"@cognium/project-profile-detect": "1.1.1",
|
|
69
|
-
"circle-ir": "4.9.
|
|
70
|
+
"circle-ir": "4.9.21"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
|
-
"@types/node": "^
|
|
73
|
-
"
|
|
74
|
-
"
|
|
73
|
+
"@types/node": "^26.6.1",
|
|
74
|
+
"ajv": "^8.17.1",
|
|
75
|
+
"ajv-draft-04": "^1.0.0",
|
|
76
|
+
"bun-types": "^1.4.2",
|
|
77
|
+
"typescript": "^7.0.2"
|
|
75
78
|
}
|
|
76
79
|
}
|