@codemod.com/codemod-sandbox 0.1.3 → 0.1.5

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.
@@ -11,10 +11,10 @@ class Capabilities {
11
11
  const parsedInputs = JSON.parse(inputData);
12
12
  const isOutputOperation = capabilityName === "output";
13
13
  const { $metadata, ...cleanInputs } = parsedInputs;
14
- const actualInputs = (!isOutputOperation && $metadata) ? cleanInputs : parsedInputs;
14
+ const actualInputs = !isOutputOperation && $metadata ? cleanInputs : parsedInputs;
15
15
  let result;
16
16
  try {
17
- result = await handler(actualInputs, []) || {};
17
+ result = (await handler(actualInputs, [])) || {};
18
18
  }
19
19
  catch (error) {
20
20
  result = {
@@ -3,15 +3,14 @@ export default function _default(): {
3
3
  __wbg_set_wasm: (val: any) => void;
4
4
  initializeTreeSitter: (locate_file?: Function | null) => Promise<void>;
5
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>;
6
+ run_module: (invocation_id: string, method: string, name: string, modules: any, code: string, json: string) => Promise<any>;
8
7
  scanFind: (src: string, configs: any[]) => any;
9
8
  scanFix: (src: string, configs: any[]) => string;
10
9
  dumpASTNodes: (src: string) => any;
11
10
  dumpPattern: (src: string, selector?: string | null) => any;
12
11
  __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;
12
+ __wbg_atob_410cd81516b5d2c0: (arg0: any, arg1: any, arg2: any) => void;
13
+ __wbg_btoa_607ab8a9e28af18a: (arg0: any, arg1: any, arg2: any) => void;
15
14
  __wbg_buffer_609cc3eee51ed158: (arg0: any) => any;
16
15
  __wbg_call_672a4d21634d4a24: (...args: any[]) => any;
17
16
  __wbg_call_7cccdd69e0791ae2: (...args: any[]) => any;
@@ -28,8 +27,8 @@ export default function _default(): {
28
27
  __wbg_endIndex_d3aa1552abc6599c: (arg0: any) => any;
29
28
  __wbg_endPosition_a4796193570eccbd: (arg0: any) => any;
30
29
  __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>;
30
+ __wbg_error_b70b501f8bfc3e9f: (arg0: any, arg1: any) => void;
31
+ __wbg_fetch_cfe126521bd5ab4d: (arg0: any, arg1: any, arg2: any, arg3: any) => Promise<string>;
33
32
  __wbg_fieldIdForName_ed243dd7e35f4861: (arg0: any, arg1: any, arg2: any) => any;
34
33
  __wbg_from_2a5d3e218e67aa85: (arg0: any) => any[];
35
34
  __wbg_get_67b2ba62fc30de12: (...args: any[]) => any;
@@ -53,7 +52,7 @@ export default function _default(): {
53
52
  __wbg_length_a446193dc22c12f8: (arg0: any) => any;
54
53
  __wbg_length_e2d2a49132c1b256: (arg0: any) => any;
55
54
  __wbg_load_ac005a13bbebdb0b: (arg0: any, arg1: any) => Promise<Language>;
56
- __wbg_log_b79a24d377a91090: (arg0: any, arg1: any) => void;
55
+ __wbg_log_82a1aa28dec023ca: (arg0: any, arg1: any) => void;
57
56
  __wbg_message_97a2af9b89d693a3: (arg0: any) => any;
58
57
  __wbg_namedChildCount_44a0f24db74f4d08: (arg0: any) => any;
59
58
  __wbg_new_23a2665fac83c611: (arg0: any, arg1: any) => Promise<any>;
@@ -68,8 +67,8 @@ export default function _default(): {
68
67
  __wbg_next_6574e1a8a62d1055: (...args: any[]) => any;
69
68
  __wbg_parent_647e5f3765673032: (arg0: any) => any;
70
69
  __wbg_parse_211b75b6b50e2da5: (...args: any[]) => any;
71
- __wbg_parse_def2e24ef1252aff: (...args: any[]) => any;
72
70
  __wbg_previousSibling_0d5cdd5a811cedb2: (arg0: any) => any;
71
+ __wbg_push_737cfc8c1432c2c6: (arg0: any, arg1: any) => any;
73
72
  __wbg_queueMicrotask_97d92b4fcc8a61c5: (arg0: any) => void;
74
73
  __wbg_queueMicrotask_d3219def82552485: (arg0: any) => any;
75
74
  __wbg_resolve_4851785c9c5f573d: (arg0: any) => Promise<any>;
@@ -94,13 +93,13 @@ export default function _default(): {
94
93
  __wbg_type_8c03f5de5dcc70e8: (arg0: any) => any;
95
94
  __wbg_value_cd1ffa7b1ab794f1: (arg0: any) => any;
96
95
  __wbg_walk_5a10ef3cc747c1a7: (arg0: any) => any;
97
- __wbg_warn_dec08065228a61fc: (arg0: any, arg1: any) => void;
96
+ __wbg_warn_77e725bc6baf77a6: (arg0: any, arg1: any) => void;
98
97
  __wbindgen_bigint_from_i64: (arg0: any) => any;
99
98
  __wbindgen_bigint_from_u64: (arg0: any) => bigint;
100
99
  __wbindgen_bigint_get_as_i64: (arg0: any, arg1: any) => void;
101
100
  __wbindgen_boolean_get: (arg0: any) => 0 | 1 | 2;
102
101
  __wbindgen_cb_drop: (arg0: any) => boolean;
103
- __wbindgen_closure_wrapper4812: (arg0: any, arg1: any, arg2: any) => {
102
+ __wbindgen_closure_wrapper6684: (arg0: any, arg1: any, arg2: any) => {
104
103
  (...args: any[]): any;
105
104
  original: {
106
105
  a: any;
@@ -229,37 +229,6 @@ export default function () {
229
229
  const ret = wasm.setupParser(ptr0, len0, ptr1, len1);
230
230
  return ret;
231
231
  }
232
- function takeFromExternrefTable0(idx) {
233
- const value = wasm.__wbindgen_export_4.get(idx);
234
- wasm.__externref_table_dealloc(idx);
235
- return value;
236
- }
237
- /**
238
- * @param {string} code
239
- * @returns {string}
240
- */
241
- function eval_code(code) {
242
- let deferred3_0;
243
- let deferred3_1;
244
- try {
245
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
246
- const len0 = WASM_VECTOR_LEN;
247
- const ret = wasm.eval_code(ptr0, len0);
248
- var ptr2 = ret[0];
249
- var len2 = ret[1];
250
- if (ret[3]) {
251
- ptr2 = 0;
252
- len2 = 0;
253
- throw takeFromExternrefTable0(ret[2]);
254
- }
255
- deferred3_0 = ptr2;
256
- deferred3_1 = len2;
257
- return getStringFromWasm0(ptr2, len2);
258
- }
259
- finally {
260
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
261
- }
262
- }
263
232
  /**
264
233
  * @param {string} invocation_id
265
234
  * @param {string} method
@@ -267,7 +236,7 @@ export default function () {
267
236
  * @param {any} modules
268
237
  * @param {string} code
269
238
  * @param {string} json
270
- * @returns {Promise<string>}
239
+ * @returns {Promise<any>}
271
240
  */
272
241
  function run_module(invocation_id, method, name, modules, code, json) {
273
242
  const ptr0 = passStringToWasm0(invocation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -283,6 +252,11 @@ export default function () {
283
252
  const ret = wasm.run_module(ptr0, len0, ptr1, len1, ptr2, len2, modules, ptr3, len3, ptr4, len4);
284
253
  return ret;
285
254
  }
255
+ function takeFromExternrefTable0(idx) {
256
+ const value = wasm.__wbindgen_export_4.get(idx);
257
+ wasm.__externref_table_dealloc(idx);
258
+ return value;
259
+ }
286
260
  /**
287
261
  * @param {string} src
288
262
  * @param {any[]} configs
@@ -358,10 +332,10 @@ export default function () {
358
332
  return takeFromExternrefTable0(ret[0]);
359
333
  }
360
334
  function __wbg_adapter_50(arg0, arg1, arg2) {
361
- wasm.closure1704_externref_shim(arg0, arg1, arg2);
335
+ wasm.closure2325_externref_shim(arg0, arg1, arg2);
362
336
  }
363
- function __wbg_adapter_199(arg0, arg1, arg2, arg3) {
364
- wasm.closure1726_externref_shim(arg0, arg1, arg2, arg3);
337
+ function __wbg_adapter_200(arg0, arg1, arg2, arg3) {
338
+ wasm.closure2347_externref_shim(arg0, arg1, arg2, arg3);
365
339
  }
366
340
  function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
367
341
  const ret = String(arg1);
@@ -371,7 +345,7 @@ export default function () {
371
345
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
372
346
  }
373
347
  ;
374
- function __wbg_atob_b687cf564517d11e(arg0, arg1, arg2) {
348
+ function __wbg_atob_410cd81516b5d2c0(arg0, arg1, arg2) {
375
349
  const ret = atob(getStringFromWasm0(arg1, arg2));
376
350
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
377
351
  const len1 = WASM_VECTOR_LEN;
@@ -379,7 +353,7 @@ export default function () {
379
353
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
380
354
  }
381
355
  ;
382
- function __wbg_btoa_f1cc8b23625c1733(arg0, arg1, arg2) {
356
+ function __wbg_btoa_607ab8a9e28af18a(arg0, arg1, arg2) {
383
357
  const ret = btoa(getStringFromWasm0(arg1, arg2));
384
358
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
385
359
  const len1 = WASM_VECTOR_LEN;
@@ -474,13 +448,13 @@ export default function () {
474
448
  return ret;
475
449
  }
476
450
  ;
477
- function __wbg_error_55b26df739c2fe8b(arg0, arg1) {
451
+ function __wbg_error_b70b501f8bfc3e9f(arg0, arg1) {
478
452
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
479
453
  wasm.__wbindgen_free(arg0, arg1 * 4, 4);
480
454
  console.error(...v0);
481
455
  }
482
456
  ;
483
- function __wbg_fetch_71724d6f0f8d9962(arg0, arg1, arg2, arg3) {
457
+ function __wbg_fetch_cfe126521bd5ab4d(arg0, arg1, arg2, arg3) {
484
458
  let deferred0_0;
485
459
  let deferred0_1;
486
460
  let deferred1_0;
@@ -644,7 +618,7 @@ export default function () {
644
618
  return ret;
645
619
  }
646
620
  ;
647
- function __wbg_log_b79a24d377a91090(arg0, arg1) {
621
+ function __wbg_log_82a1aa28dec023ca(arg0, arg1) {
648
622
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
649
623
  wasm.__wbindgen_free(arg0, arg1 * 4, 4);
650
624
  console.log(...v0);
@@ -667,7 +641,7 @@ export default function () {
667
641
  const a = state0.a;
668
642
  state0.a = 0;
669
643
  try {
670
- return __wbg_adapter_199(a, state0.b, arg0, arg1);
644
+ return __wbg_adapter_200(a, state0.b, arg0, arg1);
671
645
  }
672
646
  finally {
673
647
  state0.a = a;
@@ -742,18 +716,16 @@ export default function () {
742
716
  }, arguments);
743
717
  }
744
718
  ;
745
- function __wbg_parse_def2e24ef1252aff() {
746
- return handleError(function (arg0, arg1) {
747
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
748
- return ret;
749
- }, arguments);
750
- }
751
- ;
752
719
  function __wbg_previousSibling_0d5cdd5a811cedb2(arg0) {
753
720
  const ret = arg0.previousSibling;
754
721
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
755
722
  }
756
723
  ;
724
+ function __wbg_push_737cfc8c1432c2c6(arg0, arg1) {
725
+ const ret = arg0.push(arg1);
726
+ return ret;
727
+ }
728
+ ;
757
729
  function __wbg_queueMicrotask_97d92b4fcc8a61c5(arg0) {
758
730
  queueMicrotask(arg0);
759
731
  }
@@ -873,7 +845,7 @@ export default function () {
873
845
  return ret;
874
846
  }
875
847
  ;
876
- function __wbg_warn_dec08065228a61fc(arg0, arg1) {
848
+ function __wbg_warn_77e725bc6baf77a6(arg0, arg1) {
877
849
  var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
878
850
  wasm.__wbindgen_free(arg0, arg1 * 4, 4);
879
851
  console.warn(...v0);
@@ -912,8 +884,8 @@ export default function () {
912
884
  return ret;
913
885
  }
914
886
  ;
915
- function __wbindgen_closure_wrapper4812(arg0, arg1, arg2) {
916
- const ret = makeMutClosure(arg0, arg1, 1705, __wbg_adapter_50);
887
+ function __wbindgen_closure_wrapper6684(arg0, arg1, arg2) {
888
+ const ret = makeMutClosure(arg0, arg1, 2326, __wbg_adapter_50);
917
889
  return ret;
918
890
  }
919
891
  ;
@@ -1022,15 +994,14 @@ export default function () {
1022
994
  __wbg_set_wasm,
1023
995
  initializeTreeSitter,
1024
996
  setupParser,
1025
- eval_code,
1026
997
  run_module,
1027
998
  scanFind,
1028
999
  scanFix,
1029
1000
  dumpASTNodes,
1030
1001
  dumpPattern,
1031
1002
  __wbg_String_8f0eb39a4a4c2f66,
1032
- __wbg_atob_b687cf564517d11e,
1033
- __wbg_btoa_f1cc8b23625c1733,
1003
+ __wbg_atob_410cd81516b5d2c0,
1004
+ __wbg_btoa_607ab8a9e28af18a,
1034
1005
  __wbg_buffer_609cc3eee51ed158,
1035
1006
  __wbg_call_672a4d21634d4a24,
1036
1007
  __wbg_call_7cccdd69e0791ae2,
@@ -1047,8 +1018,8 @@ export default function () {
1047
1018
  __wbg_endIndex_d3aa1552abc6599c,
1048
1019
  __wbg_endPosition_a4796193570eccbd,
1049
1020
  __wbg_entries_3265d4158b33e5dc,
1050
- __wbg_error_55b26df739c2fe8b,
1051
- __wbg_fetch_71724d6f0f8d9962,
1021
+ __wbg_error_b70b501f8bfc3e9f,
1022
+ __wbg_fetch_cfe126521bd5ab4d,
1052
1023
  __wbg_fieldIdForName_ed243dd7e35f4861,
1053
1024
  __wbg_from_2a5d3e218e67aa85,
1054
1025
  __wbg_get_67b2ba62fc30de12,
@@ -1072,7 +1043,7 @@ export default function () {
1072
1043
  __wbg_length_a446193dc22c12f8,
1073
1044
  __wbg_length_e2d2a49132c1b256,
1074
1045
  __wbg_load_ac005a13bbebdb0b,
1075
- __wbg_log_b79a24d377a91090,
1046
+ __wbg_log_82a1aa28dec023ca,
1076
1047
  __wbg_message_97a2af9b89d693a3,
1077
1048
  __wbg_namedChildCount_44a0f24db74f4d08,
1078
1049
  __wbg_new_23a2665fac83c611,
@@ -1087,8 +1058,8 @@ export default function () {
1087
1058
  __wbg_next_6574e1a8a62d1055,
1088
1059
  __wbg_parent_647e5f3765673032,
1089
1060
  __wbg_parse_211b75b6b50e2da5,
1090
- __wbg_parse_def2e24ef1252aff,
1091
1061
  __wbg_previousSibling_0d5cdd5a811cedb2,
1062
+ __wbg_push_737cfc8c1432c2c6,
1092
1063
  __wbg_queueMicrotask_97d92b4fcc8a61c5,
1093
1064
  __wbg_queueMicrotask_d3219def82552485,
1094
1065
  __wbg_resolve_4851785c9c5f573d,
@@ -1113,13 +1084,13 @@ export default function () {
1113
1084
  __wbg_type_8c03f5de5dcc70e8,
1114
1085
  __wbg_value_cd1ffa7b1ab794f1,
1115
1086
  __wbg_walk_5a10ef3cc747c1a7,
1116
- __wbg_warn_dec08065228a61fc,
1087
+ __wbg_warn_77e725bc6baf77a6,
1117
1088
  __wbindgen_bigint_from_i64,
1118
1089
  __wbindgen_bigint_from_u64,
1119
1090
  __wbindgen_bigint_get_as_i64,
1120
1091
  __wbindgen_boolean_get,
1121
1092
  __wbindgen_cb_drop,
1122
- __wbindgen_closure_wrapper4812,
1093
+ __wbindgen_closure_wrapper6684,
1123
1094
  __wbindgen_debug_string,
1124
1095
  __wbindgen_error_new,
1125
1096
  __wbindgen_in,
@@ -1,6 +1,6 @@
1
- import { ConsoleStdout, OpenFile, WASI, File as WasiFile, } from "@bjorn3/browser_wasi_shim";
2
1
  import { readFile } from "node:fs/promises";
3
2
  import { fileURLToPath } from "node:url";
3
+ import { ConsoleStdout, OpenFile, WASI, File as WasiFile, } from "@bjorn3/browser_wasi_shim";
4
4
  import factory from "./factory.js";
5
5
  export { NodeSandbox };
6
6
  async function loadWasmRuntime() {
@@ -80,6 +80,6 @@ class NodeSandbox {
80
80
  this.clearLogs();
81
81
  const instance = await this.getWasmInstance();
82
82
  const executionResult = await instance.run_module(sessionId, operation, moduleName, moduleRegistry, moduleCode, JSON.stringify(moduleInputs));
83
- return JSON.parse(executionResult);
83
+ return executionResult;
84
84
  }
85
85
  }
@@ -56,7 +56,7 @@ class WebSandbox {
56
56
  const inputData = JSON.stringify(moduleInputs);
57
57
  console.debug(...formatDataSize(`Run module: "${moduleName}": input size`, inputData.length));
58
58
  const executionResult = await sandboxInstance.run_module(sessionId, operation, moduleName, moduleRegistry, moduleCode, inputData);
59
- return JSON.parse(executionResult);
59
+ return executionResult;
60
60
  }
61
61
  }
62
62
  function formatDataSize(prefix, sizeInBytes) {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@codemod.com/codemod-sandbox",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Codemod Javascript Sandbox",
5
- "main": "./dist/src/index.js",
5
+ "main": "./dist/js/index.js",
6
6
  "exports": {
7
- ".": "./dist/src/index.js",
7
+ ".": "./dist/js/index.js",
8
8
  "./sandbox.wasm": "./sandbox.wasm",
9
- "./web": "./dist/src/web-exports.js",
10
- "./node": "./dist/src/node-exports.js"
9
+ "./web": "./dist/js/web-exports.js",
10
+ "./node": "./dist/js/node-exports.js"
11
11
  },
12
- "types": "dist/src/index.d.ts",
12
+ "types": "dist/js/index.d.ts",
13
13
  "type": "module",
14
14
  "scripts": {
15
15
  "prepack": "pnpm run build",
@@ -19,7 +19,7 @@
19
19
  "build:tsc": "pnpm run generate-type-declarations && tsc --project tsconfig.build.json --pretty",
20
20
  "build:runtime": "pnpm run copy-runtime-files",
21
21
  "build": "pnpm run build:runtime && pnpm run build:tsc",
22
- "lint": "pnpm run build:tsc && eslint src/ --ext .ts",
22
+ "lint": "pnpm run build:tsc && eslint js/ --ext .ts",
23
23
  "test": "pnpm run build && node --test --enable-source-maps --test-reporter spec dist/tests/*.js"
24
24
  },
25
25
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "url": "https://github.com/codemod-com/codemod"
28
28
  },
29
29
  "files": [
30
- "dist/src",
30
+ "dist/js",
31
31
  "sandbox.wasm"
32
32
  ],
33
33
  "keywords": [],
package/sandbox.wasm CHANGED
Binary file
@@ -1,16 +0,0 @@
1
- export { Telemetry };
2
- interface TelemetryConfig {
3
- enabled?: boolean;
4
- path?: number[];
5
- }
6
- declare class Telemetry {
7
- private readonly config;
8
- private operationCounter;
9
- static create(config: TelemetryConfig): undefined;
10
- constructor(config: TelemetryConfig);
11
- startModule(): Promise<void>;
12
- startCapability(): Promise<number>;
13
- endCapability(): Promise<void>;
14
- endModule(): Promise<void>;
15
- invocationPath(path: number): number[];
16
- }
@@ -1,28 +0,0 @@
1
- // Simplified telemetry implementation - functionality removed per requirements
2
- export { Telemetry };
3
- class Telemetry {
4
- config;
5
- operationCounter = 0;
6
- static create(config) {
7
- // Always return undefined to effectively disable telemetry
8
- return undefined;
9
- }
10
- constructor(config) {
11
- this.config = { enabled: false, ...config };
12
- }
13
- async startModule() {
14
- // No-op implementation
15
- }
16
- async startCapability() {
17
- return ++this.operationCounter;
18
- }
19
- async endCapability() {
20
- // No-op implementation
21
- }
22
- async endModule() {
23
- // No-op implementation
24
- }
25
- invocationPath(path) {
26
- return [...(this.config.path || []), path];
27
- }
28
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes