@apm-js-collab/code-transformer 0.5.0 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apm-js-collab/code-transformer",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,12 +17,16 @@
17
17
  "types": "./pkg/orchestrion_js.d.ts",
18
18
  "scripts": {
19
19
  "build": "wasm-pack build --target nodejs --release -- --features wasm",
20
- "test": "node ./tests/wasm/tests.mjs"
20
+ "test": "vitest run",
21
+ "test:watch": "vitest"
21
22
  },
22
23
  "devDependencies": {
24
+ "source-map": "^0.7.6",
25
+ "typescript": "^5.8.3",
26
+ "vitest": "^3.2.4",
23
27
  "wasm-pack": "^0.13.1"
24
28
  },
25
29
  "volta": {
26
30
  "node": "22.15.0"
27
31
  }
28
- }
32
+ }
@@ -1,6 +1,20 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export function create(configs: InstrumentationConfig[], dc_module?: string | null): InstrumentationMatcher;
4
+ /**
5
+ * Output of a transformation operation
6
+ */
7
+ export interface TransformOutput {
8
+ /**
9
+ * The transformed JavaScript code
10
+ */
11
+ code: string;
12
+ /**
13
+ * The sourcemap for the transformation (if generated)
14
+ */
15
+ map: string | undefined;
16
+ }
17
+
4
18
  export interface InstrumentationConfig {
5
19
  channelName: string;
6
20
  module: ModuleMatcher;
@@ -27,5 +41,10 @@ export class InstrumentationMatcher {
27
41
  export class Transformer {
28
42
  private constructor();
29
43
  free(): void;
30
- transform(contents: string, is_module: ModuleType): string;
44
+ /**
45
+ * Transform the given JavaScript code with optional sourcemap support.
46
+ * # Errors
47
+ * Returns an error if the transformation fails to find injection points.
48
+ */
49
+ transform(code: string, module_type: ModuleType, sourcemap?: string | null): TransformOutput;
31
50
  }
@@ -270,29 +270,24 @@ class Transformer {
270
270
  wasm.__wbg_transformer_free(ptr, 0);
271
271
  }
272
272
  /**
273
- * @param {string} contents
274
- * @param {ModuleType} is_module
275
- * @returns {string}
273
+ * Transform the given JavaScript code with optional sourcemap support.
274
+ * # Errors
275
+ * Returns an error if the transformation fails to find injection points.
276
+ * @param {string} code
277
+ * @param {ModuleType} module_type
278
+ * @param {string | null} [sourcemap]
279
+ * @returns {TransformOutput}
276
280
  */
277
- transform(contents, is_module) {
278
- let deferred3_0;
279
- let deferred3_1;
280
- try {
281
- const ptr0 = passStringToWasm0(contents, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
282
- const len0 = WASM_VECTOR_LEN;
283
- const ret = wasm.transformer_transform(this.__wbg_ptr, ptr0, len0, is_module);
284
- var ptr2 = ret[0];
285
- var len2 = ret[1];
286
- if (ret[3]) {
287
- ptr2 = 0; len2 = 0;
288
- throw takeFromExternrefTable0(ret[2]);
289
- }
290
- deferred3_0 = ptr2;
291
- deferred3_1 = len2;
292
- return getStringFromWasm0(ptr2, len2);
293
- } finally {
294
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
281
+ transform(code, module_type, sourcemap) {
282
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283
+ const len0 = WASM_VECTOR_LEN;
284
+ var ptr1 = isLikeNone(sourcemap) ? 0 : passStringToWasm0(sourcemap, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
285
+ var len1 = WASM_VECTOR_LEN;
286
+ const ret = wasm.transformer_transform(this.__wbg_ptr, ptr0, len0, module_type, ptr1, len1);
287
+ if (ret[2]) {
288
+ throw takeFromExternrefTable0(ret[1]);
295
289
  }
290
+ return takeFromExternrefTable0(ret[0]);
296
291
  }
297
292
  }
298
293
  module.exports.Transformer = Transformer;
@@ -398,6 +393,11 @@ module.exports.__wbg_length_e2d2a49132c1b256 = function(arg0) {
398
393
  return ret;
399
394
  };
400
395
 
396
+ module.exports.__wbg_new_405e22f390576ce2 = function() {
397
+ const ret = new Object();
398
+ return ret;
399
+ };
400
+
401
401
  module.exports.__wbg_new_a12002a7f91c75be = function(arg0) {
402
402
  const ret = new Uint8Array(arg0);
403
403
  return ret;
@@ -413,6 +413,10 @@ module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(fun
413
413
  return ret;
414
414
  }, arguments) };
415
415
 
416
+ module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
417
+ arg0[arg1] = arg2;
418
+ };
419
+
416
420
  module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
417
421
  arg0.set(arg1, arg2 >>> 0);
418
422
  };
Binary file