mc-pdf-studio 1.0.1 → 1.0.2
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/package.json +1 -1
- package/src/server.js +36 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mc-pdf-studio",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "MC PDF Studio — a beautiful PDF viewer CLI with dark/light themes, minimap navigation, and a multi-provider AI Sidekick (Claude, Ollama, OpenAI, xAI)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
package/src/server.js
CHANGED
|
@@ -215,36 +215,47 @@ When the user asks about specific pages or content, refer to the PDF context pro
|
|
|
215
215
|
|
|
216
216
|
// ─── Server Start ──────────────────────────────────────────────────────────
|
|
217
217
|
|
|
218
|
-
function
|
|
218
|
+
function printBanner(port, config) {
|
|
219
|
+
const url = `http://localhost:${port}`;
|
|
220
|
+
console.log('');
|
|
221
|
+
console.log(' ╔═══════════════════════════════════════╗');
|
|
222
|
+
console.log(' ║ ✦ MC PDF Studio Ready ✦ ║');
|
|
223
|
+
console.log(' ╚═══════════════════════════════════════╝');
|
|
224
|
+
console.log('');
|
|
225
|
+
console.log(` → Local: ${url}`);
|
|
226
|
+
if (config.initialFile) console.log(` → File: ${path.basename(config.initialFile)}`);
|
|
227
|
+
if (config.enableAi) {
|
|
228
|
+
const prov = config.aiProvider || 'anthropic';
|
|
229
|
+
const mod = config.aiModel || (PROVIDER_DEFAULTS[prov] || {}).model || '';
|
|
230
|
+
console.log(` → AI: Sidekick enabled ✓ (${prov} / ${mod})`);
|
|
231
|
+
}
|
|
232
|
+
console.log(` → Theme: ${config.theme}`);
|
|
233
|
+
console.log('');
|
|
234
|
+
console.log(' Press Ctrl+C to stop');
|
|
235
|
+
console.log('');
|
|
236
|
+
|
|
237
|
+
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
238
|
+
try { require('child_process').exec(`${cmd} ${url}`); } catch(e) {}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function start(config, port) {
|
|
219
242
|
CONFIG = config;
|
|
243
|
+
port = port || config.port;
|
|
220
244
|
|
|
221
245
|
const server = http.createServer(app);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (config.enableAi) {
|
|
232
|
-
const prov = config.aiProvider || 'anthropic';
|
|
233
|
-
const mod = config.aiModel || (PROVIDER_DEFAULTS[prov] || {}).model || '';
|
|
234
|
-
console.log(` → AI: Sidekick enabled ✓ (${prov} / ${mod})`);
|
|
246
|
+
|
|
247
|
+
server.once('error', (err) => {
|
|
248
|
+
if (err.code === 'EADDRINUSE') {
|
|
249
|
+
console.warn(` ⚠ Port ${port} is busy — trying ${port + 1}…`);
|
|
250
|
+
server.close();
|
|
251
|
+
start(config, port + 1);
|
|
252
|
+
} else {
|
|
253
|
+
console.error(' ✗ Server error:', err.message);
|
|
254
|
+
process.exit(1);
|
|
235
255
|
}
|
|
236
|
-
console.log(` → Theme: ${config.theme}`);
|
|
237
|
-
console.log('');
|
|
238
|
-
console.log(' Press Ctrl+C to stop');
|
|
239
|
-
console.log('');
|
|
240
|
-
|
|
241
|
-
// Auto-open browser
|
|
242
|
-
const open = (url) => {
|
|
243
|
-
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open';
|
|
244
|
-
require('child_process').exec(`${cmd} ${url}`);
|
|
245
|
-
};
|
|
246
|
-
try { open(url); } catch(e) {}
|
|
247
256
|
});
|
|
257
|
+
|
|
258
|
+
server.listen(port, () => printBanner(port, config));
|
|
248
259
|
}
|
|
249
260
|
|
|
250
261
|
module.exports = { start };
|