mrmd-server 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/server.js +16 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrmd-server",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "HTTP server for mrmd - run mrmd in any browser, access from anywhere",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -46,7 +46,7 @@
46
46
  "chokidar": "^3.6.0",
47
47
  "fzf": "^0.5.2",
48
48
  "mrmd-project": "^0.1.1",
49
- "mrmd-electron": "^0.3.1",
49
+ "mrmd-electron": "^0.3.2",
50
50
  "mrmd-sync": "^0.3.2"
51
51
  }
52
52
  }
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
- // In npx/installed context, it might be in node_modules
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)) {