@codemod.com/codemod-sandbox 0.1.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/src/capabilities.d.ts +12 -0
- package/dist/src/capabilities.js +43 -0
- package/dist/src/factory.d.ts +134 -0
- package/dist/src/factory.js +1143 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +3 -0
- package/dist/src/module.d.ts +13 -0
- package/dist/src/module.js +46 -0
- package/dist/src/node-exports.d.ts +1 -0
- package/dist/src/node-exports.js +1 -0
- package/dist/src/node.d.ts +18 -0
- package/dist/src/node.js +69 -0
- package/dist/src/telemetry.d.ts +16 -0
- package/dist/src/telemetry.js +28 -0
- package/dist/src/type-declarations.d.ts +1 -0
- package/dist/src/type-declarations.js +26 -0
- package/dist/src/types.d.ts +26 -0
- package/dist/src/types.js +1 -0
- package/dist/src/web-exports.d.ts +1 -0
- package/dist/src/web-exports.js +1 -0
- package/dist/src/web.d.ts +18 -0
- package/dist/src/web.js +91 -0
- package/package.json +49 -0
- package/sandbox.wasm +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UUID } from "./types.js";
|
|
2
|
+
import type { CapabilityRegistry } from "./types.js";
|
|
3
|
+
export { fetch, Capabilities };
|
|
4
|
+
declare class Capabilities {
|
|
5
|
+
private readonly contextMap;
|
|
6
|
+
private static globalInstance;
|
|
7
|
+
invoke(sessionId: UUID, capabilityName: string, inputData: string): Promise<string>;
|
|
8
|
+
install(sessionId: UUID, capabilities: CapabilityRegistry): void;
|
|
9
|
+
uninstall(sessionId: UUID): void;
|
|
10
|
+
static instance(): Capabilities;
|
|
11
|
+
}
|
|
12
|
+
declare function fetch(sessionId: UUID, inputData: string): Promise<string>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export { fetch, Capabilities };
|
|
2
|
+
class Capabilities {
|
|
3
|
+
contextMap = new Map();
|
|
4
|
+
static globalInstance = new Capabilities();
|
|
5
|
+
async invoke(sessionId, capabilityName, inputData) {
|
|
6
|
+
const context = this.contextMap.get(sessionId);
|
|
7
|
+
const handler = context?.registry.get(capabilityName);
|
|
8
|
+
if (!context || !handler) {
|
|
9
|
+
throw new Error(`Capability "${capabilityName}" is not available for session "${sessionId}".`);
|
|
10
|
+
}
|
|
11
|
+
const parsedInputs = JSON.parse(inputData);
|
|
12
|
+
const isOutputOperation = capabilityName === "output";
|
|
13
|
+
const { $metadata, ...cleanInputs } = parsedInputs;
|
|
14
|
+
const actualInputs = (!isOutputOperation && $metadata) ? cleanInputs : parsedInputs;
|
|
15
|
+
let result;
|
|
16
|
+
try {
|
|
17
|
+
result = await handler(actualInputs, []) || {};
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
result = {
|
|
21
|
+
$error: `Unable to invoke capability: ${error.message}`,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return JSON.stringify(result);
|
|
25
|
+
}
|
|
26
|
+
install(sessionId, capabilities) {
|
|
27
|
+
if (this.contextMap.has(sessionId)) {
|
|
28
|
+
throw new Error(`Session ID collision: "${sessionId}" capabilities were already installed.`);
|
|
29
|
+
}
|
|
30
|
+
this.contextMap.set(sessionId, {
|
|
31
|
+
registry: new Map(Object.entries(capabilities)),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
uninstall(sessionId) {
|
|
35
|
+
this.contextMap.delete(sessionId);
|
|
36
|
+
}
|
|
37
|
+
static instance() {
|
|
38
|
+
return Capabilities.globalInstance;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function fetch(sessionId, inputData) {
|
|
42
|
+
return Capabilities.instance().invoke(sessionId, "fetch", inputData);
|
|
43
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export default function _default(): {
|
|
2
|
+
[RAW_WASM]: undefined;
|
|
3
|
+
__wbg_set_wasm: (val: any) => void;
|
|
4
|
+
initializeTreeSitter: (locate_file?: Function | null) => Promise<void>;
|
|
5
|
+
setupParser: (lang_name: string, parser_path: string) => Promise<void>;
|
|
6
|
+
eval_code: (code: string) => string;
|
|
7
|
+
run_module: (invocation_id: string, method: string, name: string, modules: any, code: string, json: string) => Promise<string>;
|
|
8
|
+
scanFind: (src: string, configs: any[]) => any;
|
|
9
|
+
scanFix: (src: string, configs: any[]) => string;
|
|
10
|
+
dumpASTNodes: (src: string) => any;
|
|
11
|
+
dumpPattern: (src: string, selector?: string | null) => any;
|
|
12
|
+
__wbg_String_8f0eb39a4a4c2f66: (arg0: any, arg1: any) => void;
|
|
13
|
+
__wbg_atob_b687cf564517d11e: (arg0: any, arg1: any, arg2: any) => void;
|
|
14
|
+
__wbg_btoa_f1cc8b23625c1733: (arg0: any, arg1: any, arg2: any) => void;
|
|
15
|
+
__wbg_buffer_609cc3eee51ed158: (arg0: any) => any;
|
|
16
|
+
__wbg_call_672a4d21634d4a24: (...args: any[]) => any;
|
|
17
|
+
__wbg_call_7cccdd69e0791ae2: (...args: any[]) => any;
|
|
18
|
+
__wbg_childCount_a6b8bf01a93e53da: (arg0: any) => any;
|
|
19
|
+
__wbg_childForFieldId_e1ff577760482763: (arg0: any, arg1: any) => any;
|
|
20
|
+
__wbg_childForFieldName_c30c3ad6e6d7b2d5: (arg0: any, arg1: any, arg2: any) => any;
|
|
21
|
+
__wbg_child_1ecd54afc9b93ff5: (arg0: any, arg1: any) => any;
|
|
22
|
+
__wbg_children_9c7bca8276138d26: (arg0: any, arg1: any) => void;
|
|
23
|
+
__wbg_column_e22f48f18c5be5af: (arg0: any) => any;
|
|
24
|
+
__wbg_currentFieldId_45a539bb96e00de6: (arg0: any) => any;
|
|
25
|
+
__wbg_currentFieldName_2bf460c2ff4cb55f: (arg0: any) => any;
|
|
26
|
+
__wbg_currentNode_71762eadafc49fc0: (arg0: any) => any;
|
|
27
|
+
__wbg_done_769e5ede4b31c67b: (arg0: any) => any;
|
|
28
|
+
__wbg_endIndex_d3aa1552abc6599c: (arg0: any) => any;
|
|
29
|
+
__wbg_endPosition_a4796193570eccbd: (arg0: any) => any;
|
|
30
|
+
__wbg_entries_3265d4158b33e5dc: (arg0: any) => [string, any][];
|
|
31
|
+
__wbg_error_55b26df739c2fe8b: (arg0: any, arg1: any) => void;
|
|
32
|
+
__wbg_fetch_71724d6f0f8d9962: (arg0: any, arg1: any, arg2: any, arg3: any) => Promise<string>;
|
|
33
|
+
__wbg_fieldIdForName_ed243dd7e35f4861: (arg0: any, arg1: any, arg2: any) => any;
|
|
34
|
+
__wbg_from_2a5d3e218e67aa85: (arg0: any) => any[];
|
|
35
|
+
__wbg_get_67b2ba62fc30de12: (...args: any[]) => any;
|
|
36
|
+
__wbg_get_b9b93047fe3cf45b: (arg0: any, arg1: any) => any;
|
|
37
|
+
__wbg_getwithrefkey_1dc361bd10053bfe: (arg0: any, arg1: any) => any;
|
|
38
|
+
__wbg_gotoFirstChild_252ce106a4886852: (arg0: any) => any;
|
|
39
|
+
__wbg_gotoNextSibling_04b8655b389f7e62: (arg0: any) => any;
|
|
40
|
+
__wbg_gotoParent_667cb6debc76112d: (arg0: any) => any;
|
|
41
|
+
__wbg_idForNodeType_f69d5a20ec58af31: (arg0: any, arg1: any, arg2: any, arg3: any) => any;
|
|
42
|
+
__wbg_id_46703548bec1f10b: (arg0: any) => any;
|
|
43
|
+
__wbg_init_89fd7d76d7bb0691: (arg0: any) => Promise<void>;
|
|
44
|
+
__wbg_instanceof_ArrayBuffer_e14585432e3737fc: (arg0: any) => boolean;
|
|
45
|
+
__wbg_instanceof_Error_4d54113b22d20306: (arg0: any) => boolean;
|
|
46
|
+
__wbg_instanceof_Map_f3469ce2244d2430: (arg0: any) => boolean;
|
|
47
|
+
__wbg_instanceof_Uint8Array_17156bcf118086a9: (arg0: any) => boolean;
|
|
48
|
+
__wbg_isArray_a1eab7e0d067391b: (arg0: any) => arg0 is any[];
|
|
49
|
+
__wbg_isMissing_fdcbb1d762ec3abf: (arg0: any) => any;
|
|
50
|
+
__wbg_isNamed_e49e788404dd0c6b: (arg0: any) => any;
|
|
51
|
+
__wbg_isSafeInteger_343e2beeeece1bb0: (arg0: any) => boolean;
|
|
52
|
+
__wbg_iterator_9a24c88df860dc65: () => symbol;
|
|
53
|
+
__wbg_length_a446193dc22c12f8: (arg0: any) => any;
|
|
54
|
+
__wbg_length_e2d2a49132c1b256: (arg0: any) => any;
|
|
55
|
+
__wbg_load_ac005a13bbebdb0b: (arg0: any, arg1: any) => Promise<Language>;
|
|
56
|
+
__wbg_log_b79a24d377a91090: (arg0: any, arg1: any) => void;
|
|
57
|
+
__wbg_message_97a2af9b89d693a3: (arg0: any) => any;
|
|
58
|
+
__wbg_namedChildCount_44a0f24db74f4d08: (arg0: any) => any;
|
|
59
|
+
__wbg_new_23a2665fac83c611: (arg0: any, arg1: any) => Promise<any>;
|
|
60
|
+
__wbg_new_405e22f390576ce2: () => Object;
|
|
61
|
+
__wbg_new_5e0be73521bc8c17: () => Map<any, any>;
|
|
62
|
+
__wbg_new_617dbf964b61f53e: (...args: any[]) => any;
|
|
63
|
+
__wbg_new_78feb108b6472713: () => any[];
|
|
64
|
+
__wbg_new_a12002a7f91c75be: (arg0: any) => Uint8Array<any>;
|
|
65
|
+
__wbg_newnoargs_105ed471475aaf50: (arg0: any, arg1: any) => Function;
|
|
66
|
+
__wbg_nextSibling_b371f151ed94a89b: (arg0: any) => any;
|
|
67
|
+
__wbg_next_25feadfc0913fea9: (arg0: any) => any;
|
|
68
|
+
__wbg_next_6574e1a8a62d1055: (...args: any[]) => any;
|
|
69
|
+
__wbg_parent_647e5f3765673032: (arg0: any) => any;
|
|
70
|
+
__wbg_parse_211b75b6b50e2da5: (...args: any[]) => any;
|
|
71
|
+
__wbg_parse_def2e24ef1252aff: (...args: any[]) => any;
|
|
72
|
+
__wbg_previousSibling_0d5cdd5a811cedb2: (arg0: any) => any;
|
|
73
|
+
__wbg_queueMicrotask_97d92b4fcc8a61c5: (arg0: any) => void;
|
|
74
|
+
__wbg_queueMicrotask_d3219def82552485: (arg0: any) => any;
|
|
75
|
+
__wbg_resolve_4851785c9c5f573d: (arg0: any) => Promise<any>;
|
|
76
|
+
__wbg_rootNode_5b87afbf1cb30f6f: (arg0: any) => any;
|
|
77
|
+
__wbg_row_3a241ac449e90b14: (arg0: any) => any;
|
|
78
|
+
__wbg_setLanguage_183086649e428443: (...args: any[]) => any;
|
|
79
|
+
__wbg_set_37837023f3d740e8: (arg0: any, arg1: any, arg2: any) => void;
|
|
80
|
+
__wbg_set_3f1d0b984ed272ed: (arg0: any, arg1: any, arg2: any) => void;
|
|
81
|
+
__wbg_set_65595bdd868b3009: (arg0: any, arg1: any, arg2: any) => void;
|
|
82
|
+
__wbg_set_8fc6bf8a5b1071d1: (arg0: any, arg1: any, arg2: any) => any;
|
|
83
|
+
__wbg_set_bb8cecf6a62b9f46: (...args: any[]) => any;
|
|
84
|
+
__wbg_startIndex_466622c3156f49af: (arg0: any) => any;
|
|
85
|
+
__wbg_startPosition_222a04896d7d160c: (arg0: any) => any;
|
|
86
|
+
__wbg_static_accessor_GLOBAL_88a902d13a557d07: () => any;
|
|
87
|
+
__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0: () => any;
|
|
88
|
+
__wbg_static_accessor_SELF_37c5d418e4bf5819: () => any;
|
|
89
|
+
__wbg_static_accessor_WINDOW_5de37043a91a9c40: () => any;
|
|
90
|
+
__wbg_text_8bf8fa91111a698f: (arg0: any) => any;
|
|
91
|
+
__wbg_then_44b73946d2fb3e7d: (arg0: any, arg1: any) => any;
|
|
92
|
+
__wbg_then_48b406749878a531: (arg0: any, arg1: any, arg2: any) => any;
|
|
93
|
+
__wbg_typeId_e158ac425466c562: (arg0: any) => any;
|
|
94
|
+
__wbg_type_8c03f5de5dcc70e8: (arg0: any) => any;
|
|
95
|
+
__wbg_value_cd1ffa7b1ab794f1: (arg0: any) => any;
|
|
96
|
+
__wbg_walk_5a10ef3cc747c1a7: (arg0: any) => any;
|
|
97
|
+
__wbg_warn_dec08065228a61fc: (arg0: any, arg1: any) => void;
|
|
98
|
+
__wbindgen_bigint_from_i64: (arg0: any) => any;
|
|
99
|
+
__wbindgen_bigint_from_u64: (arg0: any) => bigint;
|
|
100
|
+
__wbindgen_bigint_get_as_i64: (arg0: any, arg1: any) => void;
|
|
101
|
+
__wbindgen_boolean_get: (arg0: any) => 0 | 1 | 2;
|
|
102
|
+
__wbindgen_cb_drop: (arg0: any) => boolean;
|
|
103
|
+
__wbindgen_closure_wrapper4812: (arg0: any, arg1: any, arg2: any) => {
|
|
104
|
+
(...args: any[]): any;
|
|
105
|
+
original: {
|
|
106
|
+
a: any;
|
|
107
|
+
b: any;
|
|
108
|
+
cnt: number;
|
|
109
|
+
dtor: any;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
__wbindgen_debug_string: (arg0: any, arg1: any) => void;
|
|
113
|
+
__wbindgen_error_new: (arg0: any, arg1: any) => Error;
|
|
114
|
+
__wbindgen_in: (arg0: any, arg1: any) => boolean;
|
|
115
|
+
__wbindgen_init_externref_table: () => void;
|
|
116
|
+
__wbindgen_is_bigint: (arg0: any) => arg0 is bigint;
|
|
117
|
+
__wbindgen_is_function: (arg0: any) => boolean;
|
|
118
|
+
__wbindgen_is_object: (arg0: any) => boolean;
|
|
119
|
+
__wbindgen_is_string: (arg0: any) => arg0 is string;
|
|
120
|
+
__wbindgen_is_undefined: (arg0: any) => boolean;
|
|
121
|
+
__wbindgen_jsval_eq: (arg0: any, arg1: any) => boolean;
|
|
122
|
+
__wbindgen_jsval_loose_eq: (arg0: any, arg1: any) => boolean;
|
|
123
|
+
__wbindgen_memory: () => any;
|
|
124
|
+
__wbindgen_number_get: (arg0: any, arg1: any) => void;
|
|
125
|
+
__wbindgen_number_new: (arg0: any) => any;
|
|
126
|
+
__wbindgen_string_get: (arg0: any, arg1: any) => void;
|
|
127
|
+
__wbindgen_string_new: (arg0: any, arg1: any) => any;
|
|
128
|
+
__wbindgen_throw: (arg0: any, arg1: any) => void;
|
|
129
|
+
Parser: typeof Parser;
|
|
130
|
+
Language: typeof Language;
|
|
131
|
+
};
|
|
132
|
+
export const RAW_WASM: unique symbol;
|
|
133
|
+
import { Language } from 'web-tree-sitter';
|
|
134
|
+
import { Parser } from 'web-tree-sitter';
|