Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@bytecodealliance/jco-std

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bytecodealliance/jco-std - npm Package Compare versions

Comparing version
0.0.2
to
0.1.0
+38
dist/0.2.3/http/adapters/hono/middleware/config.d.ts
import { type WasiConfigHelper } from '../../../../../0.2.x/config.js';
export type { WasiConfigHelper } from '../../../../../0.2.x/config.js';
export type WASIConfigMiddleware = {
Variables: {
config: WasiConfigHelper;
};
};
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export declare const wasiConfigMiddleware: () => import("hono").MiddlewareHandler<WASIConfigMiddleware, string, {}, Response>;
//# sourceMappingURL=config.d.ts.map
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../../src/wasi/0.2.3/http/adapters/hono/middleware/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElG,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,MAAM,MAAM,oBAAoB,GAAG;IAC/B,SAAS,EAAE;QACP,MAAM,EAAE,gBAAgB,CAAC;KAC5B,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,oBAAoB,oFAKhC,CAAC"}
import { createMiddleware } from "hono/factory";
// NOTE: this import is somewhat "magical", it is filled in by componentize-js when
// building a component.
//
// Transpilers & bundlers must essentially ignore this component when building.
import * as wasiConfig from "wasi:config/store@0.2.0-rc.1";
import { buildConfigHelperFromWASI } from '../../../../../0.2.x/config.js';
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export const wasiConfigMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('config', buildConfigHelperFromWASI(wasiConfig));
await next();
});
};
import { type WasiEnvironmentHelper } from '../../../../../0.2.x/cli/environment.js';
export type { WasiEnvironmentHelper } from '../../../../../0.2.x/cli/environment.js';
export type WASIEnvMiddleware = {
Variables: {
env: WasiEnvironmentHelper;
};
};
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export declare const wasiEnvMiddleware: () => import("hono").MiddlewareHandler<WASIEnvMiddleware, string, {}, Response>;
//# sourceMappingURL=env.d.ts.map
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../../../src/wasi/0.2.3/http/adapters/hono/middleware/env.ts"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAE7G,YAAY,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,SAAS,EAAE;QACP,GAAG,EAAE,qBAAqB,CAAC;KAC9B,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,iBAAiB,iFAK7B,CAAC"}
import { createMiddleware } from "hono/factory";
// NOTE: this import is somewhat "magical", it is filled in by componentize-js when
// building a component.
//
// Transpilers & bundlers must essentially ignore this component when building.
import * as wasiEnv from "wasi:cli/environment@0.2.3";
import { buildEnvHelperFromWASI } from '../../../../../0.2.x/cli/environment.js';
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export const wasiEnvMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('env', buildEnvHelperFromWASI(wasiEnv));
await next();
});
};
import type { Hono, Schema as HonoSchema, Env as HonoEnv } from "hono";
import { type FireOpts } from '../../../../0.2.x/hono.js';
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export declare function fire<Env extends HonoEnv = HonoEnv, Schema extends HonoSchema = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type
BasePath extends string = '/'>(app: Hono<Env, Schema, BasePath>, opts?: FireOpts): void;
export { incomingHandler } from '../../../../0.2.x/hono.js';
export { buildLogger } from '../../../../0.2.x/logging.js';
//# sourceMappingURL=server.d.ts.map
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../src/wasi/0.2.3/http/adapters/hono/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,UAAU,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,MAAM,CAAC;AAEvE,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAKvE,uFAAuF;AACvF,wBAAgB,IAAI,CAChB,GAAG,SAAS,OAAO,GAAG,OAAO,EAC7B,MAAM,SAAS,UAAU,GAAG,EAAE,EAAE,8DAA8D;AAC9F,QAAQ,SAAS,MAAM,GAAG,GAAG,EAE7B,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAChC,IAAI,CAAC,EAAE,QAAQ,QAIlB;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC"}
import { buildFireFn } from '../../../../0.2.x/hono.js';
import { readWASIRequest } from '../../types/request.js';
import { writeWebResponse } from '../../types/response.js';
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export function fire(app, opts) {
const realFireFn = buildFireFn({ readWASIRequest, writeWebResponse });
realFireFn(app, opts);
}
export { incomingHandler } from '../../../../0.2.x/hono.js';
export { buildLogger } from '../../../../0.2.x/logging.js';
import { type WasiConfigHelper } from '../../../../../0.2.x/config.js';
export { type WasiConfigHelper } from '../../../../../0.2.x/config.js';
export type WASIConfigMiddleware = {
Variables: {
config: WasiConfigHelper;
};
};
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export declare const wasiConfigMiddleware: () => import("hono").MiddlewareHandler<WASIConfigMiddleware, string, {}, Response>;
//# sourceMappingURL=config.d.ts.map
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../../src/wasi/0.2.6/http/adapters/hono/middleware/config.ts"],"names":[],"mappings":"AAQA,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElG,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,MAAM,MAAM,oBAAoB,GAAG;IAC/B,SAAS,EAAE;QACP,MAAM,EAAE,gBAAgB,CAAC;KAC5B,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,oBAAoB,oFAKhC,CAAC"}
import { createMiddleware } from 'hono/factory';
// NOTE: this import is somewhat "magical", it is filled in by componentize-js when
// building a component.
//
// Transpilers & bundlers must essentially ignore this component when building.
import * as wasiConfig from "wasi:config/store@0.2.0-rc.1";
import { buildConfigHelperFromWASI } from '../../../../../0.2.x/config.js';
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export const wasiConfigMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('config', buildConfigHelperFromWASI(wasiConfig));
await next();
});
};
import { type WasiEnvironmentHelper } from '../../../../../0.2.x/cli/environment.js';
export { type WasiEnvironmentHelper } from '../../../../../0.2.x/cli/environment.js';
export type WASIEnvMiddleware = {
Variables: {
env: WasiEnvironmentHelper;
};
};
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export declare const wasiEnvMiddleware: () => import("hono").MiddlewareHandler<WASIEnvMiddleware, string, {}, Response>;
//# sourceMappingURL=env.d.ts.map
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../../../src/wasi/0.2.6/http/adapters/hono/middleware/env.ts"],"names":[],"mappings":"AAQA,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAE7G,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,SAAS,EAAE;QACP,GAAG,EAAE,qBAAqB,CAAC;KAC9B,CAAC;CACL,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,iBAAiB,iFAK7B,CAAC"}
import { createMiddleware } from 'hono/factory';
// NOTE: this import is somewhat "magical", it is filled in by componentize-js when
// building a component.
//
// Transpilers & bundlers must essentially ignore this component when building.
import * as wasiEnv from "wasi:cli/environment@0.2.6";
import { buildEnvHelperFromWASI } from '../../../../../0.2.x/cli/environment.js';
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export const wasiEnvMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('env', buildEnvHelperFromWASI(wasiEnv));
await next();
});
};
import type { Hono, Schema as HonoSchema, Env as HonoEnv } from 'hono';
import { type FireOpts } from '../../../../0.2.x/hono.js';
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export declare function fire<Env extends HonoEnv = HonoEnv, Schema extends HonoSchema = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type
BasePath extends string = '/'>(app: Hono<Env, Schema, BasePath>, opts?: FireOpts): void;
export { incomingHandler } from '../../../../0.2.x/hono.js';
export { buildLogger } from '../../../../0.2.x/logging.js';
//# sourceMappingURL=server.d.ts.map
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../../src/wasi/0.2.6/http/adapters/hono/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,UAAU,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,MAAM,CAAC;AAEvE,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAKvE,uFAAuF;AACvF,wBAAgB,IAAI,CAChB,GAAG,SAAS,OAAO,GAAG,OAAO,EAC7B,MAAM,SAAS,UAAU,GAAG,EAAE,EAAE,8DAA8D;AAC9F,QAAQ,SAAS,MAAM,GAAG,GAAG,EAE7B,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAChC,IAAI,CAAC,EAAE,QAAQ,QAIlB;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC"}
import { buildFireFn } from '../../../../0.2.x/hono.js';
import { readWASIRequest } from '../../types/request.js';
import { writeWebResponse } from '../../types/response.js';
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export function fire(app, opts) {
const realFireFn = buildFireFn({ readWASIRequest, writeWebResponse });
realFireFn(app, opts);
}
export { incomingHandler } from '../../../../0.2.x/hono.js';
export { buildLogger } from '../../../../0.2.x/logging.js';
+44
-11
{
"name": "@bytecodealliance/jco-std",
"version": "0.0.2",
"version": "0.1.0",
"description": "Library of shared functionality for use with the JS WebAssembly components",

@@ -29,14 +29,47 @@ "contributors": [

],
"types": "./dist/index.d.ts",
"main": "src/index.ts",
"exports": {
"./wasi/0.2.6/http/adapters/hono": {
"types": "./dist/0.2.6/http/adapters/hono.d.ts",
"browser": "./dist/0.2.6/http/adapters/hono.js",
"default": "./dist/0.2.6/http/adapters/hono.js"
"./wasi/0.2.x/http/adapters/hono/server": {
"types": "./dist/0.2.6/http/adapters/hono/server.d.ts",
"browser": "./dist/0.2.6/http/adapters/hono/server.js",
"default": "./dist/0.2.6/http/adapters/hono/server.js"
},
"./wasi/0.2.3/http/adapters/hono": {
"types": "./dist/0.2.3/http/adapters/hono.d.ts",
"browser": "./dist/0.2.3/http/adapters/hono.js",
"default": "./dist/0.2.3/http/adapters/hono.js"
"./wasi/0.2.x/http/adapters/hono/middleware/config": {
"types": "./dist/0.2.6/http/adapters/hono/middleware/config.d.ts",
"browser": "./dist/0.2.6/http/adapters/hono/middleware/config.js",
"default": "./dist/0.2.6/http/adapters/hono/middleware/config.js"
},
"./wasi/0.2.x/http/adapters/hono/middleware/env": {
"types": "./dist/0.2.6/http/adapters/hono/middleware/env.d.ts",
"browser": "./dist/0.2.6/http/adapters/hono/middleware/env.js",
"default": "./dist/0.2.6/http/adapters/hono/middleware/env.js"
},
"./wasi/0.2.6/http/adapters/hono/server": {
"types": "./dist/0.2.6/http/adapters/hono/server.d.ts",
"browser": "./dist/0.2.6/http/adapters/hono/server.js",
"default": "./dist/0.2.6/http/adapters/hono/server.js"
},
"./wasi/0.2.6/http/adapters/hono/middleware/config": {
"types": "./dist/0.2.6/http/adapters/hono/middleware/config.d.ts",
"browser": "./dist/0.2.6/http/adapters/hono/middleware/config.js",
"default": "./dist/0.2.6/http/adapters/hono/middleware/config.js"
},
"./wasi/0.2.6/http/adapters/hono/middleware/env": {
"types": "./dist/0.2.6/http/adapters/hono/middleware/env.d.ts",
"browser": "./dist/0.2.6/http/adapters/hono/middleware/env.js",
"default": "./dist/0.2.6/http/adapters/hono/middleware/env.js"
},
"./wasi/0.2.3/http/adapters/hono/server": {
"types": "./dist/0.2.3/http/adapters/hono/server.d.ts",
"browser": "./dist/0.2.3/http/adapters/hono/server.js",
"default": "./dist/0.2.3/http/adapters/hono/server.js"
},
"./wasi/0.2.3/http/adapters/hono/middleware/config": {
"types": "./dist/0.2.3/http/adapters/hono/middleware/config.d.ts",
"browser": "./dist/0.2.3/http/adapters/hono/middleware/config.js",
"default": "./dist/0.2.3/http/adapters/hono/middleware/config.js"
},
"./wasi/0.2.3/http/adapters/hono/middleware/env": {
"types": "./dist/0.2.3/http/adapters/hono/middleware/env.d.ts",
"browser": "./dist/0.2.3/http/adapters/hono/middleware/env.js",
"default": "./dist/0.2.3/http/adapters/hono/middleware/env.js"
}

@@ -43,0 +76,0 @@ },

@@ -31,3 +31,3 @@ # `@bytecodealliance/jco-std`

import { fire } from '@bytecodealliance/jco-std/wasi/0.2.6/http/adapters/hono';
import { fire } from '@bytecodealliance/jco-std/wasi/0.2.x/http/adapters/hono/server';

@@ -42,5 +42,11 @@ const app = new Hono();

// as componentize-js will be looking for the ES module export.
export { incomingHandler } from '@bytecodealliance/jco-std/http/adapters/hono';
export { incomingHandler } from '@bytecodealliance/jco-std/wasi/0.2.x/http/adapters/hono/server';
```
> [!NOTE]
> We use `@bytecodealliance/jco-std/wasi/0.2.x`, but if you'd like to use a specific version, you can
> use an explicitly versioned export like `@bytecodealliance/jco-std/wasi/0.2.6`.
>
> Note that using `0.2.x` is similar to using `latest`, it may change at *any* library update.
[hono]: https://hono.dev

@@ -47,0 +53,0 @@

import type { Hono, Schema as HonoSchema, Env as HonoEnv } from "hono";
import { type FireOpts } from '../../../0.2.x/hono.js';
import { type WasiConfigHelper } from '../../../0.2.x/config.js';
import { type WasiEnvironmentHelper } from '../../../0.2.x/cli/environment.js';
type WASIEnvMiddleware = {
Variables: {
env: WasiEnvironmentHelper;
};
};
type WASIConfigMiddleware = {
Variables: {
config: WasiConfigHelper;
};
};
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export declare function fire<Env extends HonoEnv = HonoEnv, Schema extends HonoSchema = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type
BasePath extends string = '/'>(app: Hono<Env, Schema, BasePath>, opts?: FireOpts): void;
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export declare const wasiEnvMiddleware: () => import("hono").MiddlewareHandler<WASIEnvMiddleware, string, {}, Response>;
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export declare const wasiConfigMiddleware: () => import("hono").MiddlewareHandler<WASIConfigMiddleware, string, {}, Response>;
export { incomingHandler } from '../../../0.2.x/hono.js';
export { buildLogger } from '../../../0.2.x/logging.js';
//# sourceMappingURL=hono.d.ts.map
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../../src/wasi/0.2.3/http/adapters/hono.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,UAAU,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,MAAM,CAAC;AAIvE,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAsBvG,KAAK,iBAAiB,GAAG;IACrB,SAAS,EAAE;QACP,GAAG,EAAE,qBAAqB,CAAC;KAC9B,CAAC;CACL,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,SAAS,EAAE;QACP,MAAM,EAAE,gBAAgB,CAAC;KAC5B,CAAC;CACL,CAAC;AAEF,uFAAuF;AACvF,wBAAgB,IAAI,CAChB,GAAG,SAAS,OAAO,GAAG,OAAO,EAC7B,MAAM,SAAS,UAAU,GAAG,EAAE,EAAE,8DAA8D;AAC9F,QAAQ,SAAS,MAAM,GAAG,GAAG,EAE7B,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAChC,IAAI,CAAC,EAAE,QAAQ,QAIlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,iBAAiB,iFAS7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,oBAAoB,oFAQhC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
import { createMiddleware } from "hono/factory";
import { buildFireFn } from '../../../0.2.x/hono.js';
import { buildConfigHelperFromWASI } from '../../../0.2.x/config.js';
import { buildEnvHelperFromWASI } from '../../../0.2.x/cli/environment.js';
import { readWASIRequest } from '../types/request.js';
import { writeWebResponse } from '../types/response.js';
/**
* NOTE the wasi imports below are in this format because a star &
* renamed import (e.g. 'import * as x from ...') will result in
* import statements that cannot be treeshaken properly in component
* which makes it through *post* transpilation.
*/
import { getEnvironment as wasiCLIEnvGetEnvironment, getArguments as wasiCLIEnvGetArguments, initialCwd as wasiCLIEnvInitialCwd, } from "wasi:cli/environment@0.2.3";
import { get as wasiConfigGet, getAll as wasiConfigGetAll, } from "wasi:config/store@0.2.0-rc.1";
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export function fire(app, opts) {
const realFireFn = buildFireFn({ readWASIRequest, writeWebResponse });
realFireFn(app, opts);
}
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export const wasiEnvMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('env', buildEnvHelperFromWASI({
getEnvironment: wasiCLIEnvGetEnvironment,
getArguments: wasiCLIEnvGetArguments,
initialCwd: wasiCLIEnvInitialCwd,
}));
await next();
});
};
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export const wasiConfigMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('config', buildConfigHelperFromWASI({
get: wasiConfigGet,
getAll: wasiConfigGetAll
}));
await next();
});
};
export { incomingHandler } from '../../../0.2.x/hono.js';
export { buildLogger } from '../../../0.2.x/logging.js';
export * as hono from "./hono.js";
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/wasi/0.2.3/http/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
export * as hono from "./hono.js";
export * as adapters from './adapters/index.js';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wasi/0.2.3/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
export * as adapters from './adapters/index.js';
export * from "./http/index.js";
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wasi/0.2.3/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
export * from "./http/index.js";
import type { Hono, Schema as HonoSchema, Env as HonoEnv } from 'hono';
import { type FireOpts } from '../../../0.2.x/hono.js';
import { type WasiConfigHelper } from '../../../0.2.x/config.js';
import { type WasiEnvironmentHelper } from '../../../0.2.x/cli/environment.js';
type WASIEnvMiddleware = {
Variables: {
env: WasiEnvironmentHelper;
};
};
type WASIConfigMiddleware = {
Variables: {
config: WasiConfigHelper;
};
};
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export declare function fire<Env extends HonoEnv = HonoEnv, Schema extends HonoSchema = {}, // eslint-disable-line @typescript-eslint/no-empty-object-type
BasePath extends string = '/'>(app: Hono<Env, Schema, BasePath>, opts?: FireOpts): void;
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export declare const wasiEnvMiddleware: () => import("hono").MiddlewareHandler<WASIEnvMiddleware, string, {}, Response>;
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export declare const wasiConfigMiddleware: () => import("hono").MiddlewareHandler<WASIConfigMiddleware, string, {}, Response>;
export { incomingHandler } from '../../../0.2.x/hono.js';
export { buildLogger } from '../../../0.2.x/logging.js';
//# sourceMappingURL=hono.d.ts.map
{"version":3,"file":"hono.d.ts","sourceRoot":"","sources":["../../../../src/wasi/0.2.6/http/adapters/hono.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,UAAU,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,MAAM,CAAC;AAMvE,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAKvG,KAAK,iBAAiB,GAAG;IACrB,SAAS,EAAE;QACP,GAAG,EAAE,qBAAqB,CAAC;KAC9B,CAAC;CACL,CAAC;AAEF,KAAK,oBAAoB,GAAG;IACxB,SAAS,EAAE;QACP,MAAM,EAAE,gBAAgB,CAAC;KAC5B,CAAC;CACL,CAAC;AAEF,uFAAuF;AACvF,wBAAgB,IAAI,CAChB,GAAG,SAAS,OAAO,GAAG,OAAO,EAC7B,MAAM,SAAS,UAAU,GAAG,EAAE,EAAE,8DAA8D;AAC9F,QAAQ,SAAS,MAAM,GAAG,GAAG,EAE7B,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAChC,IAAI,CAAC,EAAE,QAAQ,QAIlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,iBAAiB,iFAK7B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,oBAAoB,oFAKhC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
import { createMiddleware } from 'hono/factory';
import * as wasiEnv from "wasi:cli/environment@0.2.6";
import * as wasiConfig from "wasi:config/store@0.2.0-rc.1";
import { buildFireFn } from '../../../0.2.x/hono.js';
import { buildConfigHelperFromWASI } from '../../../0.2.x/config.js';
import { buildEnvHelperFromWASI } from '../../../0.2.x/cli/environment.js';
import { readWASIRequest } from '../types/request.js';
import { writeWebResponse } from '../types/response.js';
/** Analog to Hono's fire function, which sets up your Hono application to be served */
export function fire(app, opts) {
const realFireFn = buildFireFn({ readWASIRequest, writeWebResponse });
realFireFn(app, opts);
}
/**
* A Hono middleware that injects a helper that can retrieve
* environment variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiEnvMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const env = c.get('env');
* if (!env) { return c.json({ status: 'error', msg: 'missing env helper'}); }
*
* const envValue = env.getAllObject()['SOME_KEY'];
*
* return c.json({ status: 'success', data: envValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-cli
* @see https://github.com/WebAssembly/wasi-cli/blob/main/wit/environment.wit
*/
export const wasiEnvMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('env', buildEnvHelperFromWASI(wasiEnv));
await next();
});
};
/**
* A Hono middleware that injects a helper that can retrieve
* config variables from the platform on which the WebAssembly
* component is running.
*
* For example:
*
* ```
* import {
* wasiConfigMiddleware
* } from '@bytecodealliance/jco-std/wasi/0.2.3/http/adapters/hono';
*
* const app = new Hono();
*
* app.use(wasiEnvMiddleware());
*
* app.post('/', async (c) => {
* const config = c.get('config');
* if (!config) { return c.json({ status: 'error', msg: 'missing env helper'}); }
* const configValue = config.get('some-config-key');
*
* return c.json({ status: 'success', data: configValue });
* });
* ```
*
* @see https://github.com/WebAssembly/wasi-config
* @see https://github.com/WebAssembly/wasi-config/blob/main/wit/store.wit
*/
export const wasiConfigMiddleware = () => {
return createMiddleware(async (c, next) => {
c.set('config', buildConfigHelperFromWASI(wasiConfig));
await next();
});
};
export { incomingHandler } from '../../../0.2.x/hono.js';
export { buildLogger } from '../../../0.2.x/logging.js';
export * as hono from "./hono.js";
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/wasi/0.2.6/http/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"}
export * as hono from "./hono.js";
export * as adapters from './adapters/index.js';
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wasi/0.2.6/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
export * as adapters from './adapters/index.js';
export * from "./http/index.js";
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wasi/0.2.6/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
export * from "./http/index.js";