vimd 0.3.1 → 0.3.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.
package/README.md CHANGED
@@ -65,10 +65,10 @@
65
65
  ### インストール
66
66
 
67
67
  ```bash
68
- npm install -g vimd
68
+ npm install -g vimd@0.2.4
69
69
  ```
70
70
 
71
- **現在の安定版: v0.3.0**
71
+ **現在の安定版: v0.2.4**
72
72
 
73
73
  v0.2.0 からは **pandoc なしで利用可能** になりました。
74
74
  高品質な出力が必要な場合のみ pandoc をインストールしてください。
@@ -103,14 +103,18 @@ vimd config
103
103
 
104
104
  ## バージョン情報
105
105
 
106
- **安定版: v0.3.0**(最新版と同一)
106
+ **安定版: v0.2.4**
107
107
 
108
- v0.3.0 では内部アーキテクチャを刷新し、パフォーマンスを改善しました:
109
- - WebSocket 直接通信によるライブリロード(live-server 依存を削除)
110
- - バンドルサイズ 83% 削減
108
+ v0.3.x は内部アーキテクチャを刷新した実験的バージョンです。
109
+ 安定した動作を求める場合は v0.2.4 をご利用ください。
111
110
 
112
111
  安定版のインストール:
113
112
  ```bash
113
+ npm install -g vimd@0.2.4
114
+ ```
115
+
116
+ 最新版(実験的)のインストール:
117
+ ```bash
114
118
  npm install -g vimd@latest
115
119
  ```
116
120
 
@@ -37,6 +37,7 @@ export declare class WebSocketServer {
37
37
  start(): Promise<ServerStartResult>;
38
38
  /**
39
39
  * Stop the server
40
+ * Uses force termination to ensure immediate shutdown
40
41
  */
41
42
  stop(): Promise<void>;
42
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"websocket-server.d.ts","sourceRoot":"","sources":["../../src/core/websocket-server.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAA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AEjB;IAED;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;IA4GzC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC3B;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAU7C;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAc3B"}
@@ -160,27 +160,31 @@ export class WebSocketServer {
160
160
  }
161
161
  /**
162
162
  * Stop the server
163
+ * Uses force termination to ensure immediate shutdown
163
164
  */
164
165
  async stop() {
165
- // Close all WebSocket connections
166
+ // Force terminate all WebSocket clients (immediate disconnect)
167
+ // Use terminate() instead of close() to avoid waiting for graceful handshake
166
168
  for (const client of this.clients) {
167
169
  try {
168
- client.close();
170
+ client.terminate();
169
171
  }
170
172
  catch {
171
- // Ignore close errors
173
+ // Ignore termination errors
172
174
  }
173
175
  }
174
176
  this.clients.clear();
175
- // Close WebSocket server
177
+ // Close WebSocket server (should be instant now that clients are terminated)
176
178
  if (this.wsServer) {
177
179
  await new Promise((resolve) => {
178
180
  this.wsServer.close(() => resolve());
179
181
  });
180
182
  this.wsServer = null;
181
183
  }
182
- // Close HTTP server
184
+ // Force close all HTTP connections before closing server
185
+ // closeAllConnections() requires Node.js >= 18.2.0
183
186
  if (this.httpServer) {
187
+ this.httpServer.closeAllConnections();
184
188
  await new Promise((resolve) => {
185
189
  this.httpServer.close(() => resolve());
186
190
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vimd",
3
- "version": "0.3.1",
3
+ "version": "0.3.4",
4
4
  "description": "Real-time Markdown preview tool with pandoc (view markdown)",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -1,18 +0,0 @@
1
- import { ServerConfig } from '../config/types.js';
2
- export interface ServerStartResult {
3
- actualPort: number;
4
- requestedPort: number;
5
- portChanged: boolean;
6
- }
7
- export declare class LiveServer {
8
- private config;
9
- private running;
10
- private actualPort;
11
- constructor(config: ServerConfig);
12
- start(htmlPath: string): Promise<ServerStartResult>;
13
- stop(): Promise<void>;
14
- openBrowser(url: string): Promise<void>;
15
- getURL(): string;
16
- getActualPort(): number;
17
- }
18
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/core/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAMlD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,qBAAa,UAAU;IAIT,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;gBAEP,MAAM,EAAE,YAAY;IAIlC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA8DnD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUrB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7C,MAAM,IAAI,MAAM;IAIhB,aAAa,IAAI,MAAM;CAGxB"}
@@ -1,87 +0,0 @@
1
- // src/core/server.ts
2
- import liveServer from 'live-server';
3
- import { Logger } from '../utils/logger.js';
4
- import * as path from 'path';
5
- import open from 'open';
6
- export class LiveServer {
7
- constructor(config) {
8
- this.config = config;
9
- this.running = false;
10
- this.actualPort = config.port;
11
- }
12
- async start(htmlPath) {
13
- const root = path.dirname(htmlPath);
14
- const file = path.basename(htmlPath);
15
- const params = {
16
- port: this.config.port,
17
- host: this.config.host,
18
- root: root,
19
- file: file,
20
- open: false, // manually open
21
- wait: 50,
22
- logLevel: 0, // silent
23
- watch: [root], // explicitly watch the root directory
24
- };
25
- try {
26
- const server = liveServer.start(params);
27
- // Wait for server to start and get actual port
28
- const actualPort = await new Promise((resolve, reject) => {
29
- const timeout = setTimeout(() => {
30
- reject(new Error('Server start timeout'));
31
- }, 10000);
32
- server.addListener('listening', () => {
33
- clearTimeout(timeout);
34
- const address = server.address();
35
- resolve(address.port);
36
- });
37
- server.addListener('error', (err) => {
38
- clearTimeout(timeout);
39
- reject(err);
40
- });
41
- });
42
- this.actualPort = actualPort;
43
- this.running = true;
44
- const portChanged = actualPort !== this.config.port;
45
- const url = `http://${this.config.host}:${actualPort}`;
46
- if (portChanged) {
47
- Logger.warn(`Port ${this.config.port} was unavailable, using port ${actualPort}`);
48
- }
49
- Logger.success(`Server started at ${url}`);
50
- if (this.config.open) {
51
- await this.openBrowser(url);
52
- }
53
- return {
54
- actualPort,
55
- requestedPort: this.config.port,
56
- portChanged,
57
- };
58
- }
59
- catch (error) {
60
- const errorMessage = error instanceof Error ? error.message : String(error);
61
- throw new Error(`Failed to start server: ${errorMessage}`);
62
- }
63
- }
64
- async stop() {
65
- if (!this.running) {
66
- return;
67
- }
68
- liveServer.shutdown();
69
- this.running = false;
70
- Logger.info('Server stopped');
71
- }
72
- async openBrowser(url) {
73
- try {
74
- await open(url);
75
- Logger.info('Browser opened');
76
- }
77
- catch (error) {
78
- Logger.warn('Failed to open browser automatically');
79
- }
80
- }
81
- getURL() {
82
- return `http://${this.config.host}:${this.actualPort}`;
83
- }
84
- getActualPort() {
85
- return this.actualPort;
86
- }
87
- }