@difizen/libro-jupyter 0.1.18 → 0.1.19

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.
@@ -1,21 +1,14 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
2
  import { LibroCodeCellView } from '@difizen/libro-code-cell';
3
- import { CodeEditorManager } from '@difizen/libro-code-editor';
4
3
  import type { CodeEditorViewOptions, CompletionProvider, TooltipProvider } from '@difizen/libro-code-editor';
5
- import type { CellViewOptions } from '@difizen/libro-core';
6
- import { CellService } from '@difizen/libro-core';
7
- import type { LSPProvider } from '@difizen/libro-lsp';
8
- import { ILSPDocumentConnectionManager } from '@difizen/libro-lsp';
9
- import { ViewManager } from '@difizen/mana-app';
4
+ import type { LibroJupyterView } from '../libro-jupyter-view.js';
10
5
  import type { JupyterCodeCellModel } from './jupyter-code-cell-model.js';
11
6
  export declare class JupyterCodeCellView extends LibroCodeCellView {
7
+ parent: LibroJupyterView;
12
8
  view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
13
9
  model: JupyterCodeCellModel;
14
- protected readonly lspDocumentConnectionManager: ILSPDocumentConnectionManager;
15
- constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, lspDocumentConnectionManager: ILSPDocumentConnectionManager, codeEditorManager: CodeEditorManager);
16
10
  clearExecution: () => void;
17
11
  protected getEditorOption(): CodeEditorViewOptions;
18
- lspProvider: LSPProvider;
19
12
  tooltipProvider: TooltipProvider;
20
13
  completionProvider: CompletionProvider;
21
14
  run(): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"jupyter-code-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/jupyter-code-cell-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAElB,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAiB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAsB,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAQhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAkBzE,qBAEa,mBAAoB,SAAQ,iBAAiB;IAC/C,IAAI,2FAA4B;IACjC,KAAK,EAAE,oBAAoB,CAAC;IAEpC,SAAS,CAAC,QAAQ,CAAC,4BAA4B,EAAE,6BAA6B,CAAC;gBAGzD,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAE7C,4BAA4B,EAAE,6BAA6B,EAChC,iBAAiB,EAAE,iBAAiB;IAMxD,cAAc,aAQrB;cAEiB,eAAe,IAAI,qBAAqB;IAY3D,WAAW,EAAE,WAAW,CAkCtB;IAEF,eAAe,EAAE,eAAe,CAqB9B;IAEF,kBAAkB,EAAE,kBAAkB,CA8BpC;IAEa,GAAG;CA8EnB"}
1
+ {"version":3,"file":"jupyter-code-cell-view.d.ts","sourceRoot":"","sources":["../../src/cell/jupyter-code-cell-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAElB,eAAe,EAEhB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAkBzE,qBAEa,mBAAoB,SAAQ,iBAAiB;IAChD,MAAM,EAAE,gBAAgB,CAAC;IACxB,IAAI,2FAA4B;IACjC,KAAK,EAAE,oBAAoB,CAAC;IAE3B,cAAc,aAQrB;cAEiB,eAAe,IAAI,qBAAqB;IAgB3D,eAAe,EAAE,eAAe,CAqB9B;IAEF,kBAAkB,EAAE,kBAAkB,CA8BpC;IAEa,GAAG;CA8EnB"}
@@ -21,12 +21,10 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
21
21
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
22
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23
23
  import { CellEditorMemo, LibroCodeCellView } from '@difizen/libro-code-cell';
24
- import { CodeEditorManager } from '@difizen/libro-code-editor';
25
- import { CellService } from '@difizen/libro-core';
26
24
  import { KernelError } from '@difizen/libro-kernel';
27
- import { ILSPDocumentConnectionManager } from '@difizen/libro-lsp';
28
- import { inject, transient } from '@difizen/mana-app';
29
- import { view, ViewInstance, ViewManager, ViewOption } from '@difizen/mana-app';
25
+ import { LibroCellURIScheme } from '@difizen/libro-language-client';
26
+ import { transient, URI } from '@difizen/mana-app';
27
+ import { view, ViewInstance } from '@difizen/mana-app';
30
28
  import { getOrigin, useInject } from '@difizen/mana-app';
31
29
  import { l10n } from '@difizen/mana-l10n';
32
30
  import { forwardRef } from 'react';
@@ -45,12 +43,14 @@ var JupyterCodeCellComponent = /*#__PURE__*/forwardRef(function JupyterCodeCellC
45
43
  export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code-cell-view'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_LibroCodeCellView) {
46
44
  _inherits(JupyterCodeCellView, _LibroCodeCellView);
47
45
  var _super = _createSuper(JupyterCodeCellView);
48
- function JupyterCodeCellView(options, cellService, viewManager, lspDocumentConnectionManager, codeEditorManager) {
46
+ function JupyterCodeCellView() {
49
47
  var _this;
50
48
  _classCallCheck(this, JupyterCodeCellView);
51
- _this = _super.call(this, options, cellService, viewManager, codeEditorManager);
49
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
50
+ args[_key] = arguments[_key];
51
+ }
52
+ _this = _super.call.apply(_super, [this].concat(args));
52
53
  _this.view = JupyterCodeCellComponent;
53
- _this.lspDocumentConnectionManager = void 0;
54
54
  _this.clearExecution = function () {
55
55
  _this.model.clearExecution();
56
56
  Promise.resolve().then(function () {
@@ -58,129 +58,83 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
58
58
  return;
59
59
  }).catch(console.error);
60
60
  };
61
- _this.lspProvider = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
62
- var adapter, virtualEditor, virtualDocument, lspConnection;
63
- return _regeneratorRuntime().wrap(function _callee$(_context) {
64
- while (1) switch (_context.prev = _context.next) {
65
- case 0:
66
- _context.next = 2;
67
- return _this.lspDocumentConnectionManager.ready;
68
- case 2:
69
- adapter = _this.lspDocumentConnectionManager.adapters.get(_this.parent.model.id);
70
- if (adapter) {
71
- _context.next = 5;
72
- break;
73
- }
74
- throw new Error('no adapter');
75
- case 5:
76
- _context.next = 7;
77
- return adapter.ready;
78
- case 7:
79
- virtualEditor = adapter.getCellEditor(_assertThisInitialized(_this));
80
- if (virtualEditor) {
81
- _context.next = 10;
82
- break;
83
- }
84
- throw new Error('no virtual editor');
85
- case 10:
86
- // Get the associated virtual document of the opened document
87
- virtualDocument = adapter.virtualDocument;
88
- if (virtualDocument) {
89
- _context.next = 13;
90
- break;
91
- }
92
- throw new Error('no virtualDocument');
93
- case 13:
94
- // Get the LSP connection of the virtual document.
95
- lspConnection = _this.lspDocumentConnectionManager.connections.get(virtualDocument.uri);
96
- return _context.abrupt("return", {
97
- virtualDocument: virtualDocument,
98
- lspConnection: lspConnection,
99
- editor: virtualEditor
100
- });
101
- case 15:
102
- case "end":
103
- return _context.stop();
104
- }
105
- }, _callee);
106
- }));
107
61
  _this.tooltipProvider = /*#__PURE__*/function () {
108
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(option) {
62
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(option) {
109
63
  var cellContent, kernelConnection, reply, value;
110
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
111
- while (1) switch (_context2.prev = _context2.next) {
64
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
65
+ while (1) switch (_context.prev = _context.next) {
112
66
  case 0:
113
67
  cellContent = _this.model.value;
114
68
  kernelConnection = getOrigin(_this.parent.model.kernelConnection);
115
69
  if (kernelConnection) {
116
- _context2.next = 5;
70
+ _context.next = 5;
117
71
  break;
118
72
  }
119
73
  alert(l10n.t('Kernel Connection 还没有建立'));
120
- return _context2.abrupt("return", null);
74
+ return _context.abrupt("return", null);
121
75
  case 5:
122
- _context2.next = 7;
76
+ _context.next = 7;
123
77
  return kernelConnection.requestInspect({
124
78
  code: cellContent,
125
79
  cursor_pos: option.cursorPosition,
126
80
  detail_level: 1
127
81
  });
128
82
  case 7:
129
- reply = _context2.sent;
83
+ reply = _context.sent;
130
84
  value = reply.content;
131
85
  if (!(value.status !== 'ok' || !value.found)) {
132
- _context2.next = 11;
86
+ _context.next = 11;
133
87
  break;
134
88
  }
135
- return _context2.abrupt("return", null);
89
+ return _context.abrupt("return", null);
136
90
  case 11:
137
- return _context2.abrupt("return", value.data['text/plain']);
91
+ return _context.abrupt("return", value.data['text/plain']);
138
92
  case 12:
139
93
  case "end":
140
- return _context2.stop();
94
+ return _context.stop();
141
95
  }
142
- }, _callee2);
96
+ }, _callee);
143
97
  }));
144
98
  return function (_x) {
145
- return _ref2.apply(this, arguments);
99
+ return _ref.apply(this, arguments);
146
100
  };
147
101
  }();
148
102
  _this.completionProvider = /*#__PURE__*/function () {
149
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(option) {
103
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(option) {
150
104
  var cellContent, kernelConnection, reply, value;
151
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
152
- while (1) switch (_context3.prev = _context3.next) {
105
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
106
+ while (1) switch (_context2.prev = _context2.next) {
153
107
  case 0:
154
108
  cellContent = _this.model.source;
155
109
  kernelConnection = getOrigin(_this.parent.model.kernelConnection);
156
110
  if (kernelConnection) {
157
- _context3.next = 5;
111
+ _context2.next = 5;
158
112
  break;
159
113
  }
160
114
  alert(l10n.t('Kernel Connection 还没有建立'));
161
115
  throw new Error(l10n.t('Kernel Connection 还没有建立'));
162
116
  case 5:
163
- _context3.next = 7;
117
+ _context2.next = 7;
164
118
  return kernelConnection.requestComplete({
165
119
  code: cellContent,
166
120
  cursor_pos: option.cursorPosition
167
121
  });
168
122
  case 7:
169
- reply = _context3.sent;
123
+ reply = _context2.sent;
170
124
  value = reply.content;
171
125
  if (!(value.status === 'abort')) {
172
- _context3.next = 11;
126
+ _context2.next = 11;
173
127
  break;
174
128
  }
175
129
  throw new Error('abort');
176
130
  case 11:
177
131
  if (!(value.status === 'error')) {
178
- _context3.next = 13;
132
+ _context2.next = 13;
179
133
  break;
180
134
  }
181
135
  throw new Error(value.ename);
182
136
  case 13:
183
- return _context3.abrupt("return", {
137
+ return _context2.abrupt("return", {
184
138
  matches: value.matches,
185
139
  cursor_start: value.cursor_start,
186
140
  cursor_end: value.cursor_end,
@@ -188,51 +142,51 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
188
142
  });
189
143
  case 14:
190
144
  case "end":
191
- return _context3.stop();
145
+ return _context2.stop();
192
146
  }
193
- }, _callee3);
147
+ }, _callee2);
194
148
  }));
195
149
  return function (_x2) {
196
- return _ref3.apply(this, arguments);
150
+ return _ref2.apply(this, arguments);
197
151
  };
198
152
  }();
199
- _this.lspDocumentConnectionManager = lspDocumentConnectionManager;
200
153
  return _this;
201
154
  }
202
- JupyterCodeCellView = inject(CodeEditorManager)(JupyterCodeCellView, undefined, 4) || JupyterCodeCellView;
203
- JupyterCodeCellView = inject(ILSPDocumentConnectionManager)(JupyterCodeCellView, undefined, 3) || JupyterCodeCellView;
204
- JupyterCodeCellView = inject(ViewManager)(JupyterCodeCellView, undefined, 2) || JupyterCodeCellView;
205
- JupyterCodeCellView = inject(CellService)(JupyterCodeCellView, undefined, 1) || JupyterCodeCellView;
206
- JupyterCodeCellView = inject(ViewOption)(JupyterCodeCellView, undefined, 0) || JupyterCodeCellView;
207
155
  _createClass(JupyterCodeCellView, [{
208
156
  key: "getEditorOption",
209
157
  value: function getEditorOption() {
210
158
  var options = _get(_getPrototypeOf(JupyterCodeCellView.prototype), "getEditorOption", this).call(this);
159
+ var uri = new URI(this.parent.model.filePath);
160
+ uri = URI.withScheme(uri, LibroCellURIScheme);
161
+ uri = URI.withQuery(uri, "cellid=".concat(this.model.id));
211
162
  return _objectSpread(_objectSpread({}, options), {}, {
163
+ uuid: uri.toString(),
212
164
  tooltipProvider: this.tooltipProvider,
213
- completionProvider: this.completionProvider,
214
- lspProvider: this.parent.model.lspEnabled ? this.lspProvider : undefined
165
+ completionProvider: this.completionProvider
166
+ // lspProvider: (this.parent.model as LibroJupyterModel).lspEnabled
167
+ // ? this.lspProvider
168
+ // : undefined,
215
169
  });
216
170
  }
217
171
  }, {
218
172
  key: "run",
219
173
  value: function () {
220
- var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
174
+ var _run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
221
175
  var libroModel, kernelConnection, cellContent, cellModel, future, startTimeStr, msgPromise, endTimeStr;
222
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
223
- while (1) switch (_context4.prev = _context4.next) {
176
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
177
+ while (1) switch (_context3.prev = _context3.next) {
224
178
  case 0:
225
179
  libroModel = this.parent.model;
226
180
  if (!(!libroModel || !(libroModel instanceof LibroJupyterModel) || !libroModel.kernelConnection || libroModel.kernelConnection.isDisposed)) {
227
- _context4.next = 3;
181
+ _context3.next = 3;
228
182
  break;
229
183
  }
230
- return _context4.abrupt("return", false);
184
+ return _context3.abrupt("return", false);
231
185
  case 3:
232
186
  kernelConnection = getOrigin(libroModel.kernelConnection);
233
187
  cellContent = this.model.source;
234
188
  cellModel = this.model;
235
- _context4.prev = 6;
189
+ _context3.prev = 6;
236
190
  // if (this.outputArea instanceof LibroOutputArea)
237
191
  // this.outputArea.lastOutputContainerHeight =
238
192
  // this.outputArea.container?.current?.clientHeight;
@@ -264,10 +218,10 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
264
218
  future.onReply = function (msg) {
265
219
  cellModel.msgChangeEmitter.fire(msg);
266
220
  };
267
- _context4.next = 15;
221
+ _context3.next = 15;
268
222
  return future.done;
269
223
  case 15:
270
- msgPromise = _context4.sent;
224
+ msgPromise = _context3.sent;
271
225
  cellModel.executing = false;
272
226
  cellModel.kernelExecuting = false;
273
227
  startTimeStr = msgPromise.metadata['started'];
@@ -275,36 +229,36 @@ export var JupyterCodeCellView = (_dec = transient(), _dec2 = view('jupyter-code
275
229
  cellModel.metadata.execution['shell.execute_reply.started'] = startTimeStr;
276
230
  cellModel.metadata.execution['shell.execute_reply.end'] = endTimeStr;
277
231
  if (msgPromise) {
278
- _context4.next = 24;
232
+ _context3.next = 24;
279
233
  break;
280
234
  }
281
- return _context4.abrupt("return", true);
235
+ return _context3.abrupt("return", true);
282
236
  case 24:
283
237
  if (!(msgPromise.content.status === 'ok')) {
284
- _context4.next = 28;
238
+ _context3.next = 28;
285
239
  break;
286
240
  }
287
- return _context4.abrupt("return", true);
241
+ return _context3.abrupt("return", true);
288
242
  case 28:
289
243
  throw new KernelError(msgPromise.content);
290
244
  case 29:
291
- _context4.next = 36;
245
+ _context3.next = 36;
292
246
  break;
293
247
  case 31:
294
- _context4.prev = 31;
295
- _context4.t0 = _context4["catch"](6);
296
- if (!_context4.t0.message.startsWith('Canceled')) {
297
- _context4.next = 35;
248
+ _context3.prev = 31;
249
+ _context3.t0 = _context3["catch"](6);
250
+ if (!_context3.t0.message.startsWith('Canceled')) {
251
+ _context3.next = 35;
298
252
  break;
299
253
  }
300
- return _context4.abrupt("return", false);
254
+ return _context3.abrupt("return", false);
301
255
  case 35:
302
- throw _context4.t0;
256
+ throw _context3.t0;
303
257
  case 36:
304
258
  case "end":
305
- return _context4.stop();
259
+ return _context3.stop();
306
260
  }
307
- }, _callee4, this, [[6, 31]]);
261
+ }, _callee3, this, [[6, 31]]);
308
262
  }));
309
263
  function run() {
310
264
  return _run.apply(this, arguments);
@@ -21,7 +21,7 @@ export function CellExecutionTip(_ref) {
21
21
  _useState2 = _slicedToArray(_useState, 2),
22
22
  setCurrentTime = _useState2[1];
23
23
  var observableCell = useObserve(cell);
24
- if (!ExecutableCellView.is(cell)) {
24
+ if (!ExecutableCellView.is(observableCell)) {
25
25
  return null;
26
26
  }
27
27
  if (!ExecutableCellModel.is(observableCell.model)) {
@@ -30,7 +30,7 @@ export function CellExecutionTip(_ref) {
30
30
  var isHidden = observableCell.model.hasOutputHidden;
31
31
  var kernelExecuting = cell.model.kernelExecuting;
32
32
  var executionInfo = parseExecutionInfoFromModel(cell.model);
33
- var output = cell.outputArea.outputs;
33
+ var output = observableCell.outputArea.outputs;
34
34
  var existOutput = output && output.length !== 0;
35
35
  var waitingExecute = isWaitingExecute(observableCell.model);
36
36
  if (!executionInfo) {
@@ -152,7 +152,7 @@ export var LibroNavigatableView = (_dec = transient(), _dec2 = view(LibroNavigat
152
152
  return _context2.abrupt("return");
153
153
  case 5:
154
154
  this.libroView = libroView;
155
- this.libroView.model.onContentChanged(function () {
155
+ this.libroView.model.onChanged(function () {
156
156
  _this3.dirty = true;
157
157
  _this3.dirtyEmitter.fire();
158
158
  if (_this3.autoSave === 'on') {
@@ -3,9 +3,11 @@ import { VirtualizedManagerHelper } from '@difizen/libro-core';
3
3
  import { CollapseServiceFactory, NotebookService } from '@difizen/libro-core';
4
4
  import { LibroView } from '@difizen/libro-core';
5
5
  import { URI } from '@difizen/mana-app';
6
+ import type { LibroJupyterModel } from './libro-jupyter-model.js';
6
7
  export declare class LibroJupyterView extends LibroView {
7
8
  uri: URI;
9
+ model: LibroJupyterModel;
8
10
  constructor(options: NotebookOption, collapseServiceFactory: CollapseServiceFactory, notebookService: NotebookService, virtualizedManagerHelper: VirtualizedManagerHelper);
9
- get options(): import("@difizen/libro-core").Options;
11
+ get options(): NotebookOption;
10
12
  }
11
13
  //# sourceMappingURL=libro-jupyter-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"libro-jupyter-view.d.ts","sourceRoot":"","sources":["../src/libro-jupyter-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,GAAG,EAAoB,MAAM,mBAAmB,CAAC;AAG1D,qBAEa,gBAAiB,SAAQ,SAAS;IAC7C,GAAG,EAAE,GAAG,CAAC;gBAEa,OAAO,EAAE,cAAc,EACX,sBAAsB,EAAE,sBAAsB,EACrD,eAAe,EAAE,eAAe,EAEzD,wBAAwB,EAAE,wBAAwB;IAOpD,IAAI,OAAO,0CAEV;CACF"}
1
+ {"version":3,"file":"libro-jupyter-view.d.ts","sourceRoot":"","sources":["../src/libro-jupyter-view.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,GAAG,EAAoB,MAAM,mBAAmB,CAAC;AAG1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,qBAEa,gBAAiB,SAAQ,SAAS;IAC7C,GAAG,EAAE,GAAG,CAAC;IACD,KAAK,EAAE,iBAAiB,CAAC;gBAEX,OAAO,EAAE,cAAc,EACX,sBAAsB,EAAE,sBAAsB,EACrD,eAAe,EAAE,eAAe,EAEzD,wBAAwB,EAAE,wBAAwB;IAOpD,IAAI,OAAO,mBAEV;CACF"}
package/es/module.js CHANGED
@@ -3,7 +3,7 @@ import { CodeMirrorEditorModule } from '@difizen/libro-codemirror';
3
3
  import { LibroE2EditorModule } from '@difizen/libro-cofine-editor';
4
4
  import { CellExecutionTimeProvider, CellInputBottonBlankProvider, LibroAddCellModule, LibroKeybindRegistry, LibroModel, LibroModule, LibroToolbarModule } from '@difizen/libro-core';
5
5
  import { LibroKernelManageModule } from '@difizen/libro-kernel';
6
- import { LibroLSPModule } from '@difizen/libro-lsp';
6
+ import { LibroLanguageClientModule } from '@difizen/libro-language-client';
7
7
  import { MarkdownCellModule } from '@difizen/libro-markdown-cell';
8
8
  import { DisplayDataOutputModule, ErrorOutputModule, StreamOutputModule } from '@difizen/libro-output';
9
9
  import { RawCellModule } from '@difizen/libro-raw-cell';
@@ -45,6 +45,6 @@ export var LibroJupyterModule = ManaModule.create().register(LibroJupyterFileSer
45
45
  }, {
46
46
  token: LibroCodeCellView,
47
47
  useClass: JupyterCodeCellView
48
- }).dependOn(LibroModule, CodeCellModule, MarkdownCellModule, RawCellModule, StreamOutputModule, ErrorOutputModule, DisplayDataOutputModule, LibroToolbarModule, LibroKernelManageModule, LibroSearchModule, SearchCodeCellModule, LibroAddCellModule, LibroLSPModule, LibroE2EditorModule, CodeMirrorEditorModule,
48
+ }).dependOn(LibroModule, CodeCellModule, MarkdownCellModule, RawCellModule, StreamOutputModule, ErrorOutputModule, DisplayDataOutputModule, LibroToolbarModule, LibroKernelManageModule, LibroSearchModule, SearchCodeCellModule, LibroAddCellModule, LibroE2EditorModule, CodeMirrorEditorModule,
49
49
  // custom module
50
- LibroBetweenCellModule, KeybindInstructionsModule, PlotlyModule, LibroJupyterFileModule);
50
+ LibroBetweenCellModule, KeybindInstructionsModule, PlotlyModule, LibroJupyterFileModule, LibroLanguageClientModule);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@difizen/libro-jupyter",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro"
@@ -31,21 +31,22 @@
31
31
  "src"
32
32
  ],
33
33
  "dependencies": {
34
- "@difizen/libro-cofine-editor": "^0.1.18",
35
- "@difizen/libro-code-editor": "^0.1.18",
36
- "@difizen/libro-code-cell": "^0.1.18",
37
- "@difizen/libro-codemirror": "^0.1.18",
38
- "@difizen/libro-rendermime": "^0.1.18",
39
- "@difizen/libro-common": "^0.1.18",
40
- "@difizen/libro-core": "^0.1.18",
41
- "@difizen/libro-kernel": "^0.1.18",
42
- "@difizen/libro-l10n": "^0.1.18",
43
- "@difizen/libro-output": "^0.1.18",
44
- "@difizen/libro-search": "^0.1.18",
45
- "@difizen/libro-search-code-cell": "^0.1.18",
46
- "@difizen/libro-lsp": "^0.1.18",
47
- "@difizen/libro-markdown-cell": "^0.1.18",
48
- "@difizen/libro-raw-cell": "^0.1.18",
34
+ "@difizen/libro-cofine-editor": "^0.1.19",
35
+ "@difizen/libro-code-editor": "^0.1.19",
36
+ "@difizen/libro-code-cell": "^0.1.19",
37
+ "@difizen/libro-codemirror": "^0.1.19",
38
+ "@difizen/libro-rendermime": "^0.1.19",
39
+ "@difizen/libro-common": "^0.1.19",
40
+ "@difizen/libro-core": "^0.1.19",
41
+ "@difizen/libro-kernel": "^0.1.19",
42
+ "@difizen/libro-l10n": "^0.1.19",
43
+ "@difizen/libro-output": "^0.1.19",
44
+ "@difizen/libro-search": "^0.1.19",
45
+ "@difizen/libro-search-code-cell": "^0.1.19",
46
+ "@difizen/libro-lsp": "^0.1.19",
47
+ "@difizen/libro-markdown-cell": "^0.1.19",
48
+ "@difizen/libro-raw-cell": "^0.1.19",
49
+ "@difizen/libro-language-client": "^0.1.19",
49
50
  "@difizen/mana-app": "latest",
50
51
  "@difizen/mana-l10n": "latest",
51
52
  "@ant-design/colors": "^7.0.0",
@@ -1,5 +1,4 @@
1
1
  import { CellEditorMemo, LibroCodeCellView } from '@difizen/libro-code-cell';
2
- import { CodeEditorManager } from '@difizen/libro-code-editor';
3
2
  import type {
4
3
  CodeEditorViewOptions,
5
4
  CompletionProvider,
@@ -7,19 +6,17 @@ import type {
7
6
  TooltipProvider,
8
7
  TooltipProviderOption,
9
8
  } from '@difizen/libro-code-editor';
10
- import type { CellViewOptions } from '@difizen/libro-core';
11
- import { CellService } from '@difizen/libro-core';
12
9
  import { KernelError } from '@difizen/libro-kernel';
13
- import type { LSPConnection, LSPProvider } from '@difizen/libro-lsp';
14
- import { ILSPDocumentConnectionManager } from '@difizen/libro-lsp';
15
- import { inject, transient } from '@difizen/mana-app';
16
- import { view, ViewInstance, ViewManager, ViewOption } from '@difizen/mana-app';
10
+ import { LibroCellURIScheme } from '@difizen/libro-language-client';
11
+ import { transient, URI } from '@difizen/mana-app';
12
+ import { view, ViewInstance } from '@difizen/mana-app';
17
13
  import { getOrigin, useInject } from '@difizen/mana-app';
18
14
  import { l10n } from '@difizen/mana-l10n';
19
15
  import { forwardRef } from 'react';
20
16
 
21
17
  import { LibroJupyterModel } from '../libro-jupyter-model.js';
22
18
  import type { ExecutionMeta } from '../libro-jupyter-protocol.js';
19
+ import type { LibroJupyterView } from '../libro-jupyter-view.js';
23
20
 
24
21
  import type { JupyterCodeCellModel } from './jupyter-code-cell-model.js';
25
22
 
@@ -42,23 +39,10 @@ const JupyterCodeCellComponent = forwardRef<HTMLDivElement>(
42
39
  @transient()
43
40
  @view('jupyter-code-cell-view')
44
41
  export class JupyterCodeCellView extends LibroCodeCellView {
42
+ declare parent: LibroJupyterView;
45
43
  override view = JupyterCodeCellComponent;
46
44
  declare model: JupyterCodeCellModel;
47
45
 
48
- protected readonly lspDocumentConnectionManager: ILSPDocumentConnectionManager;
49
-
50
- constructor(
51
- @inject(ViewOption) options: CellViewOptions,
52
- @inject(CellService) cellService: CellService,
53
- @inject(ViewManager) viewManager: ViewManager,
54
- @inject(ILSPDocumentConnectionManager)
55
- lspDocumentConnectionManager: ILSPDocumentConnectionManager,
56
- @inject(CodeEditorManager) codeEditorManager: CodeEditorManager,
57
- ) {
58
- super(options, cellService, viewManager, codeEditorManager);
59
- this.lspDocumentConnectionManager = lspDocumentConnectionManager;
60
- }
61
-
62
46
  override clearExecution = () => {
63
47
  this.model.clearExecution();
64
48
  Promise.resolve()
@@ -71,52 +55,20 @@ export class JupyterCodeCellView extends LibroCodeCellView {
71
55
 
72
56
  protected override getEditorOption(): CodeEditorViewOptions {
73
57
  const options = super.getEditorOption();
58
+ let uri = new URI(this.parent.model.filePath);
59
+ uri = URI.withScheme(uri, LibroCellURIScheme);
60
+ uri = URI.withQuery(uri, `cellid=${this.model.id}`);
74
61
  return {
75
62
  ...options,
63
+ uuid: uri.toString(),
76
64
  tooltipProvider: this.tooltipProvider,
77
65
  completionProvider: this.completionProvider,
78
- lspProvider: (this.parent.model as LibroJupyterModel).lspEnabled
79
- ? this.lspProvider
80
- : undefined,
66
+ // lspProvider: (this.parent.model as LibroJupyterModel).lspEnabled
67
+ // ? this.lspProvider
68
+ // : undefined,
81
69
  };
82
70
  }
83
71
 
84
- lspProvider: LSPProvider = async () => {
85
- await this.lspDocumentConnectionManager.ready;
86
- const adapter = this.lspDocumentConnectionManager.adapters.get(
87
- this.parent.model.id,
88
- );
89
- if (!adapter) {
90
- throw new Error('no adapter');
91
- }
92
-
93
- await adapter.ready;
94
-
95
- const virtualEditor = adapter.getCellEditor(this);
96
-
97
- if (!virtualEditor) {
98
- throw new Error('no virtual editor');
99
- }
100
-
101
- // Get the associated virtual document of the opened document
102
- const virtualDocument = adapter.virtualDocument;
103
-
104
- if (!virtualDocument) {
105
- throw new Error('no virtualDocument');
106
- }
107
-
108
- // Get the LSP connection of the virtual document.
109
- const lspConnection = this.lspDocumentConnectionManager.connections.get(
110
- virtualDocument.uri,
111
- ) as LSPConnection;
112
-
113
- return {
114
- virtualDocument,
115
- lspConnection,
116
- editor: virtualEditor,
117
- };
118
- };
119
-
120
72
  tooltipProvider: TooltipProvider = async (option: TooltipProviderOption) => {
121
73
  const cellContent = this.model.value;
122
74
  const kernelConnection = getOrigin(
@@ -25,7 +25,7 @@ export function CellExecutionTip({ cell }: { cell: CellView }) {
25
25
  const [, setCurrentTime] = useState<number>();
26
26
  const observableCell = useObserve(cell);
27
27
 
28
- if (!ExecutableCellView.is(cell)) {
28
+ if (!ExecutableCellView.is(observableCell)) {
29
29
  return null;
30
30
  }
31
31
 
@@ -38,7 +38,7 @@ export function CellExecutionTip({ cell }: { cell: CellView }) {
38
38
  .kernelExecuting;
39
39
  const executionInfo = parseExecutionInfoFromModel(cell.model);
40
40
 
41
- const output = cell.outputArea.outputs;
41
+ const output = observableCell.outputArea.outputs;
42
42
  const existOutput = output && output.length !== 0;
43
43
 
44
44
  const waitingExecute = isWaitingExecute(observableCell.model);
@@ -141,7 +141,7 @@ export class LibroNavigatableView
141
141
  return;
142
142
  }
143
143
  this.libroView = libroView;
144
- this.libroView.model.onContentChanged(() => {
144
+ this.libroView.model.onChanged(() => {
145
145
  this.dirty = true;
146
146
  this.dirtyEmitter.fire();
147
147
  if (this.autoSave === 'on') {
@@ -5,10 +5,13 @@ import { LibroView, notebookViewFactoryId } from '@difizen/libro-core';
5
5
  import { URI, view, ViewOption } from '@difizen/mana-app';
6
6
  import { inject, transient } from '@difizen/mana-app';
7
7
 
8
+ import type { LibroJupyterModel } from './libro-jupyter-model.js';
9
+
8
10
  @transient()
9
11
  @view(notebookViewFactoryId)
10
12
  export class LibroJupyterView extends LibroView {
11
13
  uri: URI;
14
+ declare model: LibroJupyterModel;
12
15
  constructor(
13
16
  @inject(ViewOption) options: NotebookOption,
14
17
  @inject(CollapseServiceFactory) collapseServiceFactory: CollapseServiceFactory,
package/src/module.ts CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  LibroToolbarModule,
16
16
  } from '@difizen/libro-core';
17
17
  import { LibroKernelManageModule } from '@difizen/libro-kernel';
18
- import { LibroLSPModule } from '@difizen/libro-lsp';
18
+ import { LibroLanguageClientModule } from '@difizen/libro-language-client';
19
19
  import { MarkdownCellModule } from '@difizen/libro-markdown-cell';
20
20
  import {
21
21
  DisplayDataOutputModule,
@@ -102,7 +102,6 @@ export const LibroJupyterModule = ManaModule.create()
102
102
  LibroSearchModule,
103
103
  SearchCodeCellModule,
104
104
  LibroAddCellModule,
105
- LibroLSPModule,
106
105
  LibroE2EditorModule,
107
106
  CodeMirrorEditorModule,
108
107
  // custom module
@@ -110,4 +109,5 @@ export const LibroJupyterModule = ManaModule.create()
110
109
  KeybindInstructionsModule,
111
110
  PlotlyModule,
112
111
  LibroJupyterFileModule,
112
+ LibroLanguageClientModule,
113
113
  );