Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

hexo-server-live

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-server-live - npm Package Compare versions

Comparing version
0.2.9
to
0.2.10
+4
-0
CHANGELOG.md

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

## v0.2.10 (2024-01-18)
- Refactor: handle source and theme box separately.
## v0.2.9 (2024-01-17)

@@ -2,0 +6,0 @@

+40
-34

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

hexo.extend.filter.register("server_middleware", async (app) => {
hexo.extend.filter.register("server_middleware", (app) => {
const { basename, extname } = require("path");

@@ -35,17 +35,5 @@ const pkg = require("./package.json");

const onProcessAfter = function (event) {
if (event.type === "skip") return;
if (resCollection.size === 0) return;
hexo.source.on("processAfter", (event) => onProcessAfter(event, "source"));
hexo.theme.on("processAfter", (event) => onProcessAfter(event, "theme"));
const data = transformProcessedInfo(event.path);
info && log.info("Reloading due to changes...");
message =
`event: ${eventName}\n` +
`data: ${JSON.stringify(data)}\n\n`;
}
hexo.source.on("processAfter", onProcessAfter);
hexo.theme.on("processAfter", onProcessAfter);
hexo.on("generateAfter", () => {

@@ -72,24 +60,42 @@ setTimeout(() => resCollection.forEach((res) => {

function transformProcessedInfo(path) {
const base = basename(path);
const ext = extname(path);
let type = "other";
function onProcessAfter(event, box) {
if (event.type === "skip") return;
if (resCollection.size === 0) return;
const config_regex = /^_(multiconfig|config(\..+)?)\.yml/;
if (config_regex.test(base)) {
type = "config";
const base = basename(event.path);
const ext = extname(event.path);
let { path } = event;
let type;
switch (box) {
case "theme": {
if (path === "_config.yml") {
type = "config";
break;
}
else if (path.startsWith("scripts/")) {
type = null;
break;
}
else if (!path.startsWith("source/")) {
type = "other";
break;
}
}
case "source": {
const output = hexo.extend.renderer.getOutput(path);
path = "/" + path.replace(ext, `.${output}`);
type = {
css: "style",
js: "script"
}[output];
break;
}
}
else {
const output = hexo.extend.renderer.getOutput(path);
path = "/" + path.replace(/^source\//, "").replace(ext, `.${output}`);
type = {
css: "style",
js: "script"
}[output];
}
return {
path,
type
};
info && log.info("Reloading due to changes...");
message =
`event: ${eventName}\n` +
`data: ${JSON.stringify({ path, type })}\n\n`;
}
});
{
"name": "hexo-server-live",
"version": "0.2.9",
"version": "0.2.10",
"description": "Live reload while source file changed for Hexo.",

@@ -5,0 +5,0 @@ "main": "index",