@freestyle-sh/with-bun 0.1.0 → 0.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/README.md CHANGED
@@ -20,9 +20,9 @@ const { vm } = await freestyle.vms.create({
20
20
  },
21
21
  });
22
22
 
23
- const res = await vm.js.runCode(
24
- "console.log(JSON.stringify({ hello: 'world' }));"
25
- );
23
+ const res = await vm.js.runCode({
24
+ code: "console.log(JSON.stringify({ hello: 'world' }));"
25
+ });
26
26
 
27
27
  console.log(res);
28
28
  // { result: { hello: 'world' }, stdout: '{"hello":"world"}\n', statusCode: 0 }
@@ -42,7 +42,7 @@ new VmBun({
42
42
 
43
43
  ## API
44
44
 
45
- ### `vm.js.runCode(code: string)`
45
+ ### `vm.js.runCode({ code: string })`
46
46
 
47
47
  Executes JavaScript/TypeScript code in the Bun runtime.
48
48
 
package/dist/index.d.ts CHANGED
@@ -19,7 +19,9 @@ declare class VmBun extends VmWith<VmBunInstance> implements VmJavaScriptRuntime
19
19
  declare class VmBunInstance extends VmWithInstance implements VmJavaScriptRuntimeInstance {
20
20
  builder: VmBun;
21
21
  constructor(builder: VmBun);
22
- runCode<Result extends JSONValue = any>(code: string): Promise<RunCodeResponse<Result>>;
22
+ runCode<Result extends JSONValue = any>({ code, }: {
23
+ code: string;
24
+ }): Promise<RunCodeResponse<Result>>;
23
25
  }
24
26
 
25
27
  export { VmBun };
package/dist/index.js CHANGED
@@ -58,7 +58,9 @@ class VmBunInstance extends VmWithInstance {
58
58
  super();
59
59
  this.builder = builder;
60
60
  }
61
- async runCode(code) {
61
+ async runCode({
62
+ code
63
+ }) {
62
64
  const result = await this.vm.exec({
63
65
  command: `/opt/bun/bin/bun -e "${code.replace(/"/g, '\\"')}"`
64
66
  });
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@freestyle-sh/with-bun",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "private": false,
5
5
  "dependencies": {
6
6
  "freestyle-sandboxes": "^0.1.2",
7
- "@freestyle-sh/with-type-js": "^0.1.0"
7
+ "@freestyle-sh/with-type-js": "^0.2.0"
8
8
  },
9
9
  "type": "module",
10
10
  "main": "./dist/index.js",