vimd 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"folder-mode-server.d.ts","sourceRoot":"","sources":["../../../src/core/folder-mode/folder-mode-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"folder-mode-server.d.ts","sourceRoot":"","sources":["../../../src/core/folder-mode/folder-mode-server.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,iBAAiB,EAEjB,aAAa,EAEd,MAAM,YAAY,CAAC;AAKpB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;CACtB;AAUD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,OAAO,CAA0C;IACzD,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,YAAY,CAAuB;gBAE/B,OAAO,EAAE,iBAAiB;IAMtC;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAiGzC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B3B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAuCxB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;YACW,gBAAgB;IAuF9B;;OAEG;YACW,WAAW;IASzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAoBpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IASvC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;OAEG;YACW,cAAc;IAkC5B;;OAEG;IACH,OAAO,CAAC,UAAU;IASlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,OAAO,CAAC,UAAU;CAWnB"}
|
|
@@ -3,6 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import polka from 'polka';
|
|
6
|
+
import sirv from 'sirv';
|
|
6
7
|
import { WebSocketServer as WSServer, WebSocket } from 'ws';
|
|
7
8
|
import { Logger } from '../../utils/logger.js';
|
|
8
9
|
import { SessionManager } from '../../utils/session-manager.js';
|
|
@@ -63,7 +64,28 @@ export class FolderModeServer {
|
|
|
63
64
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
64
65
|
res.end(JSON.stringify(this.getWrappedTree()));
|
|
65
66
|
});
|
|
66
|
-
//
|
|
67
|
+
// Static file server for images, CSS, JS, etc.
|
|
68
|
+
const serve = sirv(this.options.rootPath, {
|
|
69
|
+
dev: true, // Disable caching for development
|
|
70
|
+
});
|
|
71
|
+
// Middleware: serve static files except for markdown/latex/root
|
|
72
|
+
app.use((req, res, next) => {
|
|
73
|
+
const url = req.url || '/';
|
|
74
|
+
// Skip API routes
|
|
75
|
+
if (url.startsWith('/api/')) {
|
|
76
|
+
return next();
|
|
77
|
+
}
|
|
78
|
+
// Skip root and markdown/latex files (handled by folder mode)
|
|
79
|
+
if (url === '/' || url.endsWith('.md') || url.endsWith('.tex') || url.endsWith('.latex')) {
|
|
80
|
+
return next();
|
|
81
|
+
}
|
|
82
|
+
// Try to serve as static file
|
|
83
|
+
serve(req, res, () => {
|
|
84
|
+
// If file not found, fall back to folder mode HTML
|
|
85
|
+
next();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
// Serve folder mode HTML for markdown/root routes
|
|
67
89
|
app.get('*', (req, res) => {
|
|
68
90
|
this.serveFolderModeHtml(req, res);
|
|
69
91
|
});
|