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.1
to
0.0.2
+62
-3
dist/0.2.3/http/adapters/hono.d.ts

@@ -5,4 +5,2 @@ import type { Hono, Schema as HonoSchema, Env as HonoEnv } from "hono";

import { type WasiEnvironmentHelper } from '../../../0.2.x/cli/environment.js';
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;
type WASIEnvMiddleware = {

@@ -13,3 +11,2 @@ Variables: {

};
export declare const wasiEnvMiddleware: () => import("hono").MiddlewareHandler<WASIEnvMiddleware, string, {}, Response>;
type WASIConfigMiddleware = {

@@ -20,2 +17,64 @@ Variables: {

};
/** 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>;

@@ -22,0 +81,0 @@ export { incomingHandler } from '../../../0.2.x/hono.js';

+1
-1

@@ -1,1 +0,1 @@

{"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;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;AAMvG,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,KAAK,iBAAiB,GAAG;IACr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BG;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 * as wasiEnv from "wasi:cli/environment@0.2.3";
import * as wasiConfig from "wasi:config/store@0.2.0-rc.1";
import { buildFireFn } from '../../../0.2.x/hono.js';

@@ -9,2 +7,11 @@ import { buildConfigHelperFromWASI } from '../../../0.2.x/config.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) {

@@ -14,11 +21,76 @@ const realFireFn = buildFireFn({ readWASIRequest, writeWebResponse });

}
/**
* 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));
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(wasiConfig));
c.set('config', buildConfigHelperFromWASI({
get: wasiConfigGet,
getAll: wasiConfigGetAll
}));
await next();

@@ -25,0 +97,0 @@ });

@@ -5,4 +5,2 @@ import type { Hono, Schema as HonoSchema, Env as HonoEnv } from 'hono';

import { type WasiEnvironmentHelper } from '../../../0.2.x/cli/environment.js';
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;
type WASIEnvMiddleware = {

@@ -13,3 +11,2 @@ Variables: {

};
export declare const wasiEnvMiddleware: () => import("hono").MiddlewareHandler<WASIEnvMiddleware, string, {}, Response>;
type WASIConfigMiddleware = {

@@ -20,2 +17,64 @@ Variables: {

};
/** 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>;

@@ -22,0 +81,0 @@ export { incomingHandler } from '../../../0.2.x/hono.js';

@@ -1,1 +0,1 @@

{"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;AA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,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"}

@@ -9,2 +9,3 @@ import { createMiddleware } from 'hono/factory';

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) {

@@ -14,2 +15,31 @@ const realFireFn = buildFireFn({ readWASIRequest, writeWebResponse });

}
/**
* 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 = () => {

@@ -21,2 +51,31 @@ return createMiddleware(async (c, 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 = () => {

@@ -23,0 +82,0 @@ return createMiddleware(async (c, next) => {

{
"name": "@bytecodealliance/jco-std",
"version": "0.0.1",
"version": "0.0.2",
"description": "Library of shared functionality for use with the JS WebAssembly components",

@@ -33,10 +33,10 @@ "contributors": [

"./wasi/0.2.6/http/adapters/hono": {
"types": "./dist/wasi/0.2.6/http/adapters/hono.d.ts",
"browser": "./dist/wasi/0.2.6/http/adapters/hono.js",
"default": "./dist/wasi/0.2.6/http/adapters/hono.js"
"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.3/http/adapters/hono": {
"types": "./dist/wasi/0.2.3/http/adapters/hono.d.ts",
"browser": "./dist/wasi/0.2.3/http/adapters/hono.js",
"default": "./dist/wasi/0.2.3/http/adapters/hono.js"
"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"
}

@@ -57,2 +57,3 @@ },

"devDependencies": {
"@bytecodealliance/componentize-js": "^0.19.3",
"@bytecodealliance/jco-transpile": "^0.1.1",

@@ -64,4 +65,5 @@ "@bytecodealliance/preview2-shim": "^0.17.5",

"typescript-eslint": "^8.43.0",
"vitest": "^4.0.8",
"which": "^5.0.0"
}
}