diff --git a/api/typescript/src/bindings/env.d.ts b/api/typescript/src/bindings/env.d.ts index 1e75d7a..6fc284c 100644 --- a/api/typescript/src/bindings/env.d.ts +++ b/api/typescript/src/bindings/env.d.ts @@ -30,59 +30,67 @@ export enum QueryType { } export class Env { - // The WebAssembly instance that this class is operating with. - // This is only available after the `instantiate` method has - // been called. + /** + * The WebAssembly instance that this class is operating with. + * This is only available after the `instantiate` method has + * been called. + */ instance: WebAssembly.Instance; - // Constructs a new instance with internal state necessary to - // manage a wasm instance. - // - // Note that this does not actually instantiate the WebAssembly - // instance or module, you'll need to call the `instantiate` - // method below to "activate" this class. + /** + * Constructs a new instance with internal state necessary to + * manage a wasm instance. + * + * Note that this does not actually instantiate the WebAssembly + * instance or module, you'll need to call the `instantiate` + * method below to "activate" this class. + */ constructor(); - // This is a low-level method which can be used to add any - // intrinsics necessary for this instance to operate to an - // import object. - // - // The `import` object given here is expected to be used later - // to actually instantiate the module this class corresponds to. - // If the `instantiate` method below actually does the - // instantiation then there's no need to call this method, but - // if you're instantiating manually elsewhere then this can be - // used to prepare the import object for external instantiation. + /** + * This is a low-level method which can be used to add any + * intrinsics necessary for this instance to operate to an + * import object. + * + * The `import` object given here is expected to be used later + * to actually instantiate the module this class corresponds to. + * If the `instantiate` method below actually does the + * instantiation then there's no need to call this method, but + * if you're instantiating manually elsewhere then this can be + * used to prepare the import object for external instantiation. + */ addToImports(imports: any): void; - // Initializes this object with the provided WebAssembly - // module/instance. - // - // This is intended to be a flexible method of instantiating - // and completion of the initialization of this class. This - // method must be called before interacting with the - // WebAssembly object. - // - // The first argument to this method is where to get the - // wasm from. This can be a whole bunch of different types, - // for example: - // - // * A precompiled `WebAssembly.Module` - // * A typed array buffer containing the wasm bytecode. - // * A `Promise` of a `Response` which is used with - // `instantiateStreaming` - // * A `Response` itself used with `instantiateStreaming`. - // * An already instantiated `WebAssembly.Instance` - // - // If necessary the module is compiled, and if necessary the - // module is instantiated. Whether or not it's necessary - // depends on the type of argument provided to - // instantiation. - // - // If instantiation is performed then the `imports` object - // passed here is the list of imports used to instantiate - // the instance. This method may add its own intrinsics to - // this `imports` object too. + /** + * Initializes this object with the provided WebAssembly + * module/instance. + * + * This is intended to be a flexible method of instantiating + * and completion of the initialization of this class. This + * method must be called before interacting with the + * WebAssembly object. + * + * The first argument to this method is where to get the + * wasm from. This can be a whole bunch of different types, + * for example: + * + * * A precompiled `WebAssembly.Module` + * * A typed array buffer containing the wasm bytecode. + * * A `Promise` of a `Response` which is used with + * `instantiateStreaming` + * * A `Response` itself used with `instantiateStreaming`. + * * An already instantiated `WebAssembly.Instance` + * + * If necessary the module is compiled, and if necessary the + * module is instantiated. Whether or not it's necessary + * depends on the type of argument provided to + * instantiation. + * + * If instantiation is performed then the `imports` object + * passed here is the list of imports used to instantiate + * the instance. This method may add its own intrinsics to + * this `imports` object too. + */ instantiate( module: WebAssembly.Module | BufferSource | Promise | Response | WebAssembly.Instance, imports?: any, @@ -95,6 +103,8 @@ export class Env { cacheSet(key: string, value: Uint8Array, ttl: number, ident: number): number; cacheGet(key: string, ident: number): number; requestGetField(fieldType: FieldType, key: string, ident: number): number; + requestSetField(fieldType: FieldType, key: string, value: Uint8Array, ident: number): number; + respSetHeader(key: string, value: string, ident: number): void; getStaticFile(name: string, ident: number): number; dbExec(queryType: QueryType, name: string, ident: number): number; getFfiResult(ptr: number, ident: number): number; diff --git a/api/typescript/src/bindings/env.js b/api/typescript/src/bindings/env.js index b2b6796..b0e95fc 100644 --- a/api/typescript/src/bindings/env.js +++ b/api/typescript/src/bindings/env.js @@ -80,6 +80,7 @@ export class Env { const ptr0 = realloc(0, 0, 1, len0 * 1); (new Uint8Array(memory.buffer, ptr0, len0 * 1)).set(new Uint8Array(val0.buffer, val0.byteOffset, len0 * 1)); this._exports['return-result'](ptr0, len0, clamp_host(arg1, 0, 4294967295)); + return undefined; } returnError(arg0, arg1, arg2) { const memory = this._exports.memory; @@ -87,6 +88,7 @@ export class Env { const ptr0 = utf8_encode(arg1, realloc, memory); const len0 = UTF8_ENCODED_LEN; this._exports['return-error'](clamp_host(arg0, -2147483648, 2147483647), ptr0, len0, clamp_host(arg2, 0, 4294967295)); + return undefined; } logMsg(arg0, arg1, arg2) { const memory = this._exports.memory; @@ -97,6 +99,7 @@ export class Env { if (!(variant1 in LogLevel)) throw new RangeError("invalid variant specified for LogLevel"); this._exports['log-msg'](ptr0, len0, Number.isInteger(variant1) ? variant1 : LogLevel[variant1], clamp_host(arg2, 0, 4294967295)); + return undefined; } fetchUrl(arg0, arg1, arg2, arg3) { const memory = this._exports.memory; @@ -154,6 +157,31 @@ export class Env { const ret = this._exports['request-get-field'](Number.isInteger(variant0) ? variant0 : FieldType[variant0], ptr1, len1, clamp_host(arg2, 0, 4294967295)); return ret; } + requestSetField(arg0, arg1, arg2, arg3) { + const memory = this._exports.memory; + const realloc = this._exports["canonical_abi_realloc"]; + const variant0 = arg0; + if (!(variant0 in FieldType)) + throw new RangeError("invalid variant specified for FieldType"); + const ptr1 = utf8_encode(arg1, realloc, memory); + const len1 = UTF8_ENCODED_LEN; + const val2 = arg2; + const len2 = val2.length; + const ptr2 = realloc(0, 0, 1, len2 * 1); + (new Uint8Array(memory.buffer, ptr2, len2 * 1)).set(new Uint8Array(val2.buffer, val2.byteOffset, len2 * 1)); + const ret = this._exports['request-set-field'](Number.isInteger(variant0) ? variant0 : FieldType[variant0], ptr1, len1, ptr2, len2, clamp_host(arg3, 0, 4294967295)); + return ret; + } + respSetHeader(arg0, arg1, arg2) { + const memory = this._exports.memory; + const realloc = this._exports["canonical_abi_realloc"]; + const ptr0 = utf8_encode(arg0, realloc, memory); + const len0 = UTF8_ENCODED_LEN; + const ptr1 = utf8_encode(arg1, realloc, memory); + const len1 = UTF8_ENCODED_LEN; + this._exports['resp-set-header'](ptr0, len0, ptr1, len1, clamp_host(arg2, 0, 4294967295)); + return undefined; + } getStaticFile(arg0, arg1) { const memory = this._exports.memory; const realloc = this._exports["canonical_abi_realloc"]; @@ -195,5 +223,6 @@ export class Env { const ptr1 = utf8_encode(arg1, realloc, memory); const len1 = UTF8_ENCODED_LEN; this._exports['return-abort'](ptr0, len0, ptr1, len1, clamp_host(arg2, 0, 4294967295), clamp_host(arg3, 0, 4294967295), clamp_host(arg4, 0, 4294967295)); + return undefined; } }