From 4adc3ae0e49b1376f4e925c8b4cb3321a98c7b1f Mon Sep 17 00:00:00 2001 From: Sebastian Wessel Date: Thu, 11 Jul 2024 18:14:07 +0100 Subject: [PATCH] chore: cleanup --- package.json | 14 +++----------- src/types/InitResponseType.ts | 32 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index dff878b..0ec6c6b 100644 --- a/package.json +++ b/package.json @@ -17,18 +17,10 @@ "package", "library" ], - "files": [ - "dist" - ], + "files": ["dist"], "tshy": { - "exclude": [ - "src/**/*.test.ts", - "vendor" - ], - "dialects": [ - "esm", - "commonjs" - ], + "exclude": ["src/**/*.test.ts", "vendor"], + "dialects": ["esm", "commonjs"], "exports": { "./package.json": "./package.json", ".": "./src/index.ts" diff --git a/src/types/InitResponseType.ts b/src/types/InitResponseType.ts index f561b37..ab450ad 100644 --- a/src/types/InitResponseType.ts +++ b/src/types/InitResponseType.ts @@ -6,17 +6,47 @@ import type { OkResponse } from './OkResponse.js' import type { OkResponseCheck } from './OkResponseCheck.js' export type InitResponseType = { + /** + * The QuickJS Arena runtime + */ vm: Arena + /** + * Dispose the sandbox. + * It should not be needed to call this, as this is done automatically + */ dispose: () => void + /** + * Execute code once and cleanup after execution. + * + * The result of the code execution must be exported with export default. + * If the code is async, it needs to be awaited on export. + * + * @example + * ```js + * const result = await evalCode('export default await asyncFunction()') + * ``` + */ evalCode: ( code: string, filename?: string, options?: Omit & { executionTimeout?: number }, ) => Promise + /** + * Compile code only, but does not execute the code. + * + * @example + * ```js + * const result = await validateCode('export default await asyncFunction()') + * ``` + */ validateCode: ( code: string, filename?: string, options?: Omit & { executionTimeout?: number }, ) => Promise - mountedFs?: IFs + /** + * the virtual filesystem + * + */ + mountedFs: IFs }