deckide 3.5.9 → 3.5.11

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/dist/server.js CHANGED
@@ -11,7 +11,7 @@ import { PORT, HOST, NODE_ENV, BASIC_AUTH_USER, BASIC_AUTH_PASSWORD, CORS_ORIGIN
11
11
  import { securityHeaders } from './middleware/security.js';
12
12
  import { corsMiddleware } from './middleware/cors.js';
13
13
  import { basicAuthMiddleware, generateWsToken, isBasicAuthEnabled } from './middleware/auth.js';
14
- import { checkDatabaseIntegrity, handleDatabaseCorruption, initializeDatabase, loadPersistedState, } from './utils/database.js';
14
+ import { checkDatabaseIntegrity, handleDatabaseCorruption, initializeDatabase, loadPersistedState, clearOrphanedTerminals, } from './utils/database.js';
15
15
  import { createWorkspaceRouter, getConfigHandler } from './routes/workspaces.js';
16
16
  import { createDeckRouter } from './routes/decks.js';
17
17
  import { createFileRouter } from './routes/files.js';
@@ -42,6 +42,7 @@ export async function createServer() {
42
42
  }
43
43
  const db = new DatabaseSync(dbPath);
44
44
  initializeDatabase(db);
45
+ clearOrphanedTerminals(db);
45
46
  // Initialize state
46
47
  const workspaces = new Map();
47
48
  const workspacePathIndex = new Map();
@@ -67,6 +67,12 @@ export function initializeDatabase(db) {
67
67
  db.exec(`CREATE INDEX IF NOT EXISTS idx_decks_workspace_id ON decks(workspace_id);`);
68
68
  db.exec(`CREATE INDEX IF NOT EXISTS idx_terminals_deck_id ON terminals(deck_id);`);
69
69
  }
70
+ export function clearOrphanedTerminals(db) {
71
+ try {
72
+ db.exec('DELETE FROM terminals');
73
+ }
74
+ catch { /* table may not exist yet */ }
75
+ }
70
76
  export function loadPersistedState(db, workspaces, workspacePathIndex, decks) {
71
77
  const workspaceRows = db
72
78
  .prepare('SELECT id, name, path, created_at FROM workspaces ORDER BY created_at ASC')
@@ -103,8 +109,23 @@ export function loadPersistedState(db, workspaces, workspacePathIndex, decks) {
103
109
  });
104
110
  }
105
111
  export function saveTerminal(db, id, deckId, title, command, createdAt) {
106
- const stmt = db.prepare('INSERT OR REPLACE INTO terminals (id, deck_id, title, command, created_at) VALUES (?, ?, ?, ?, ?)');
107
- stmt.run(id, deckId, title, command, createdAt);
112
+ const stmt = db.prepare('INSERT OR REPLACE INTO terminals (id, deck_id, title, command, buffer, created_at) VALUES (?, ?, ?, ?, ?, ?)');
113
+ stmt.run(id, deckId, title, command, '', createdAt);
114
+ }
115
+ export function updateTerminalBuffer(db, id, buffer) {
116
+ const stmt = db.prepare('UPDATE terminals SET buffer = ? WHERE id = ?');
117
+ stmt.run(buffer, id);
118
+ }
119
+ export function loadTerminals(db) {
120
+ const rows = db.prepare('SELECT id, deck_id, title, command, buffer, created_at FROM terminals ORDER BY created_at ASC').all();
121
+ return rows.map((row) => ({
122
+ id: String(row.id),
123
+ deckId: String(row.deck_id),
124
+ title: String(row.title),
125
+ command: row.command ? String(row.command) : null,
126
+ buffer: String(row.buffer ?? ''),
127
+ createdAt: String(row.created_at),
128
+ }));
108
129
  }
109
130
  export function deleteTerminal(db, id) {
110
131
  const stmt = db.prepare('DELETE FROM terminals WHERE id = ?');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deckide",
3
- "version": "3.5.9",
3
+ "version": "3.5.11",
4
4
  "description": "Deck IDE - Browser-based IDE with terminal, file explorer, and git integration",
5
5
  "type": "module",
6
6
  "bin": {