mrmd-server 0.1.1 → 0.1.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 +16 -2
package/package.json
CHANGED
package/src/server.js
CHANGED
|
@@ -11,7 +11,10 @@ import { WebSocketServer } from 'ws';
|
|
|
11
11
|
import path from 'path';
|
|
12
12
|
import fs from 'fs/promises';
|
|
13
13
|
import { existsSync } from 'fs';
|
|
14
|
-
import { fileURLToPath } from 'url';
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
15
|
+
import { createRequire } from 'module';
|
|
16
|
+
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
15
18
|
|
|
16
19
|
import { createAuthMiddleware, generateToken } from './auth.js';
|
|
17
20
|
import { EventBus } from './events.js';
|
|
@@ -335,15 +338,26 @@ export async function createServer(config) {
|
|
|
335
338
|
*/
|
|
336
339
|
function findElectronDir(fromDir) {
|
|
337
340
|
const candidates = [
|
|
341
|
+
// Development: sibling directories
|
|
338
342
|
path.join(fromDir, '../../mrmd-electron'),
|
|
339
343
|
path.join(fromDir, '../../../mrmd-electron'),
|
|
340
344
|
path.join(process.cwd(), '../mrmd-electron'),
|
|
341
345
|
path.join(process.cwd(), 'mrmd-electron'),
|
|
342
|
-
//
|
|
346
|
+
// npm/npx: node_modules relative to mrmd-server package
|
|
347
|
+
path.join(fromDir, '../node_modules/mrmd-electron'),
|
|
343
348
|
path.join(fromDir, '../../node_modules/mrmd-electron'),
|
|
349
|
+
// npm/npx: node_modules in cwd
|
|
344
350
|
path.join(process.cwd(), 'node_modules/mrmd-electron'),
|
|
345
351
|
];
|
|
346
352
|
|
|
353
|
+
// Also try require.resolve to find the package
|
|
354
|
+
try {
|
|
355
|
+
const electronPkg = path.dirname(require.resolve('mrmd-electron/package.json'));
|
|
356
|
+
candidates.unshift(electronPkg);
|
|
357
|
+
} catch (e) {
|
|
358
|
+
// mrmd-electron not found via require, continue with path search
|
|
359
|
+
}
|
|
360
|
+
|
|
347
361
|
for (const candidate of candidates) {
|
|
348
362
|
const indexPath = path.join(candidate, 'index.html');
|
|
349
363
|
if (existsSync(indexPath)) {
|