Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hono/vite-dev-server

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hono/vite-dev-server - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

91

dist/dev-server.js

@@ -46,37 +46,51 @@ import { getRequestListener } from "@hono/node-server";

}
getRequestListener(async (request) => {
let env = {};
if (options?.env) {
if (typeof options.env === "function") {
env = await options.env();
} else {
env = options.env;
getRequestListener(
async (request) => {
let env = {};
if (options?.env) {
if (typeof options.env === "function") {
env = await options.env();
} else {
env = options.env;
}
} else if (options?.cf) {
env = await cloudflarePagesGetEnv(options.cf)();
}
} else if (options?.cf) {
env = await cloudflarePagesGetEnv(options.cf)();
}
if (options?.plugins) {
for (const plugin2 of options.plugins) {
if (plugin2.env) {
env = typeof plugin2.env === "function" ? await plugin2.env() : plugin2.env;
if (options?.plugins) {
for (const plugin2 of options.plugins) {
if (plugin2.env) {
env = typeof plugin2.env === "function" ? await plugin2.env() : plugin2.env;
}
}
}
}
let response = await app.fetch(request, env, {
waitUntil: async (fn) => fn,
passThroughOnException: () => {
throw new Error("`passThroughOnException` is not supported");
const response = await app.fetch(request, env, {
waitUntil: async (fn) => fn,
passThroughOnException: () => {
throw new Error("`passThroughOnException` is not supported");
}
});
if (!(response instanceof Response)) {
throw response;
}
});
if (!(response instanceof Response)) {
const message = `The response is not an instance of "Response", but: ${response.toString()}`;
console.error(message);
response = createErrorResponse(message);
if (options?.injectClientScript !== false && response.headers.get("content-type")?.match(/^text\/html/)) {
const script = '<script>import("/@vite/client")</script>';
return injectStringToResponse(response, script);
}
return response;
},
{
errorHandler: (e) => {
let err;
if (e instanceof Error) {
err = e;
server2.ssrFixStacktrace(err);
} else if (typeof e === "string") {
err = new Error(`The response is not an instance of "Response", but: ${e}`);
} else {
err = new Error(`Unknown error: ${e}`);
}
next(err);
}
}
if (options?.injectClientScript !== false && response.headers.get("content-type")?.match(/^text\/html/)) {
const script = '<script>import("/@vite/client")</script>';
return injectStringToResponse(response, script);
}
return response;
})(req, res);
)(req, res);
};

@@ -98,21 +112,8 @@ }

}
function escapeHtml(str) {
return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
}
function createErrorResponse(body) {
return new Response(
`<html><body><pre style="white-space:pre-wrap;">${escapeHtml(body)}</pre></body></html>`,
{
status: 500,
headers: {
"content-type": "text/html;charset=utf-8"
}
}
);
}
function injectStringToResponse(response, content) {
const stream = response.body;
const newContent = new TextEncoder().encode(content);
if (!stream)
if (!stream) {
return null;
}
const reader = stream.getReader();

@@ -119,0 +120,0 @@ const newContentReader = new ReadableStream({

{
"name": "@hono/vite-dev-server",
"description": "Vite dev-server plugin for Hono",
"version": "0.4.1",
"version": "0.5.0",
"types": "dist/index.d.ts",

@@ -76,3 +76,3 @@ "module": "dist/index.js",

"dependencies": {
"@hono/node-server": "^1.4.1",
"@hono/node-server": "^1.7.0",
"miniflare": "^3.20231218.2",

@@ -79,0 +79,0 @@ "minimatch": "^9.0.3"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc