mrmd-jupyter-bridge 0.1.0 → 0.1.1
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 +6 -5
- package/src/bridge.js +16 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mrmd-jupyter-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Bidirectional sync bridge between Jupyter notebooks (.ipynb) and MRMD markdown",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
"author": "",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"yjs": "^13.6.0",
|
|
29
|
-
"y-websocket": "^2.0.0",
|
|
30
|
-
"lib0": "^0.2.0",
|
|
31
28
|
"chokidar": "^3.5.0",
|
|
32
|
-
"diff": "^5.2.0"
|
|
29
|
+
"diff": "^5.2.0",
|
|
30
|
+
"lib0": "^0.2.0",
|
|
31
|
+
"ws": "^8.19.0",
|
|
32
|
+
"y-websocket": "^2.0.0",
|
|
33
|
+
"yjs": "^13.6.0"
|
|
33
34
|
},
|
|
34
35
|
"engines": {
|
|
35
36
|
"node": ">=18.0.0"
|
package/src/bridge.js
CHANGED
|
@@ -11,6 +11,7 @@ import { watch } from 'chokidar';
|
|
|
11
11
|
import { diffChars } from 'diff';
|
|
12
12
|
import { readFileSync, writeFileSync, existsSync } from 'fs';
|
|
13
13
|
import { basename, dirname, join } from 'path';
|
|
14
|
+
import WebSocket from 'ws';
|
|
14
15
|
import {
|
|
15
16
|
ipynbToMarkdown,
|
|
16
17
|
markdownToIpynb,
|
|
@@ -45,17 +46,22 @@ export class JupyterBridge {
|
|
|
45
46
|
color: '#f59e0b', // Amber - distinguishes from monitors (green) and editors
|
|
46
47
|
debounceMs: 500,
|
|
47
48
|
log: console.log,
|
|
49
|
+
mdPath: null, // Custom shadow path (if null, uses same directory as ipynb)
|
|
48
50
|
...options,
|
|
49
51
|
};
|
|
50
52
|
|
|
51
|
-
// Derive markdown path
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
// Derive markdown path - use custom path if provided, otherwise same directory
|
|
54
|
+
if (this.options.mdPath) {
|
|
55
|
+
this.mdPath = this.options.mdPath;
|
|
56
|
+
} else {
|
|
57
|
+
const dir = dirname(ipynbPath);
|
|
58
|
+
const base = basename(ipynbPath, '.ipynb');
|
|
59
|
+
this.mdPath = join(dir, `${base}.md`);
|
|
60
|
+
}
|
|
55
61
|
|
|
56
|
-
// The room name for mrmd-sync is the
|
|
57
|
-
//
|
|
58
|
-
this.
|
|
62
|
+
// The room name for mrmd-sync is the filename without extension
|
|
63
|
+
// This matches how mrmd-editor opens documents
|
|
64
|
+
this.docName = basename(this.mdPath, '.md');
|
|
59
65
|
|
|
60
66
|
/** @type {Y.Doc} */
|
|
61
67
|
this.ydoc = new Y.Doc();
|
|
@@ -156,11 +162,12 @@ export class JupyterBridge {
|
|
|
156
162
|
return new Promise((resolve, reject) => {
|
|
157
163
|
this._log('info', 'Connecting to sync server', {
|
|
158
164
|
url: this.syncUrl,
|
|
159
|
-
doc: this.
|
|
165
|
+
doc: this.docName,
|
|
160
166
|
});
|
|
161
167
|
|
|
162
|
-
this.provider = new WebsocketProvider(this.syncUrl, this.
|
|
168
|
+
this.provider = new WebsocketProvider(this.syncUrl, this.docName, this.ydoc, {
|
|
163
169
|
connect: true,
|
|
170
|
+
WebSocketPolyfill: WebSocket,
|
|
164
171
|
});
|
|
165
172
|
|
|
166
173
|
// Set awareness - this shows up in MRMD as a collaborator
|