@difizen/libro-jupyter 0.1.17 → 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.
- package/es/cell/jupyter-code-cell-view.d.ts +2 -9
- package/es/cell/jupyter-code-cell-view.d.ts.map +1 -1
- package/es/cell/jupyter-code-cell-view.js +62 -108
- package/es/components/cell-execution-tip.js +2 -2
- package/es/file/file-command.d.ts +6 -0
- package/es/file/file-command.d.ts.map +1 -1
- package/es/file/file-command.js +45 -2
- package/es/file/file-view/index.d.ts +12 -0
- package/es/file/file-view/index.d.ts.map +1 -1
- package/es/file/file-view/index.js +137 -4
- package/es/file/navigatable-view.js +1 -1
- package/es/libro-jupyter-model.d.ts.map +1 -1
- package/es/libro-jupyter-model.js +18 -2
- package/es/libro-jupyter-protocol.d.ts +1 -0
- package/es/libro-jupyter-protocol.d.ts.map +1 -1
- package/es/libro-jupyter-protocol.js +2 -1
- package/es/libro-jupyter-view.d.ts +3 -1
- package/es/libro-jupyter-view.d.ts.map +1 -1
- package/es/module.js +3 -3
- package/package.json +17 -16
- package/src/cell/jupyter-code-cell-view.tsx +12 -60
- package/src/components/cell-execution-tip.tsx +2 -2
- package/src/file/file-command.tsx +46 -6
- package/src/file/file-view/index.tsx +90 -0
- package/src/file/navigatable-view.tsx +1 -1
- package/src/libro-jupyter-model.ts +17 -0
- package/src/libro-jupyter-protocol.ts +2 -0
- package/src/libro-jupyter-view.tsx +3 -0
- package/src/module.ts +2 -2
|
@@ -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 {
|
|
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,
|
|
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 {
|
|
28
|
-
import {
|
|
29
|
-
import { view, ViewInstance
|
|
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(
|
|
46
|
+
function JupyterCodeCellView() {
|
|
49
47
|
var _this;
|
|
50
48
|
_classCallCheck(this, JupyterCodeCellView);
|
|
51
|
-
|
|
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
|
|
62
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(option) {
|
|
109
63
|
var cellContent, kernelConnection, reply, value;
|
|
110
|
-
return _regeneratorRuntime().wrap(function
|
|
111
|
-
while (1) switch (
|
|
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
|
-
|
|
70
|
+
_context.next = 5;
|
|
117
71
|
break;
|
|
118
72
|
}
|
|
119
73
|
alert(l10n.t('Kernel Connection 还没有建立'));
|
|
120
|
-
return
|
|
74
|
+
return _context.abrupt("return", null);
|
|
121
75
|
case 5:
|
|
122
|
-
|
|
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 =
|
|
83
|
+
reply = _context.sent;
|
|
130
84
|
value = reply.content;
|
|
131
85
|
if (!(value.status !== 'ok' || !value.found)) {
|
|
132
|
-
|
|
86
|
+
_context.next = 11;
|
|
133
87
|
break;
|
|
134
88
|
}
|
|
135
|
-
return
|
|
89
|
+
return _context.abrupt("return", null);
|
|
136
90
|
case 11:
|
|
137
|
-
return
|
|
91
|
+
return _context.abrupt("return", value.data['text/plain']);
|
|
138
92
|
case 12:
|
|
139
93
|
case "end":
|
|
140
|
-
return
|
|
94
|
+
return _context.stop();
|
|
141
95
|
}
|
|
142
|
-
},
|
|
96
|
+
}, _callee);
|
|
143
97
|
}));
|
|
144
98
|
return function (_x) {
|
|
145
|
-
return
|
|
99
|
+
return _ref.apply(this, arguments);
|
|
146
100
|
};
|
|
147
101
|
}();
|
|
148
102
|
_this.completionProvider = /*#__PURE__*/function () {
|
|
149
|
-
var
|
|
103
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(option) {
|
|
150
104
|
var cellContent, kernelConnection, reply, value;
|
|
151
|
-
return _regeneratorRuntime().wrap(function
|
|
152
|
-
while (1) switch (
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
123
|
+
reply = _context2.sent;
|
|
170
124
|
value = reply.content;
|
|
171
125
|
if (!(value.status === 'abort')) {
|
|
172
|
-
|
|
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
|
-
|
|
132
|
+
_context2.next = 13;
|
|
179
133
|
break;
|
|
180
134
|
}
|
|
181
135
|
throw new Error(value.ename);
|
|
182
136
|
case 13:
|
|
183
|
-
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
|
|
145
|
+
return _context2.stop();
|
|
192
146
|
}
|
|
193
|
-
},
|
|
147
|
+
}, _callee2);
|
|
194
148
|
}));
|
|
195
149
|
return function (_x2) {
|
|
196
|
-
return
|
|
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
|
|
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
|
|
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
|
|
223
|
-
while (1) switch (
|
|
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
|
-
|
|
181
|
+
_context3.next = 3;
|
|
228
182
|
break;
|
|
229
183
|
}
|
|
230
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
221
|
+
_context3.next = 15;
|
|
268
222
|
return future.done;
|
|
269
223
|
case 15:
|
|
270
|
-
msgPromise =
|
|
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
|
-
|
|
232
|
+
_context3.next = 24;
|
|
279
233
|
break;
|
|
280
234
|
}
|
|
281
|
-
return
|
|
235
|
+
return _context3.abrupt("return", true);
|
|
282
236
|
case 24:
|
|
283
237
|
if (!(msgPromise.content.status === 'ok')) {
|
|
284
|
-
|
|
238
|
+
_context3.next = 28;
|
|
285
239
|
break;
|
|
286
240
|
}
|
|
287
|
-
return
|
|
241
|
+
return _context3.abrupt("return", true);
|
|
288
242
|
case 28:
|
|
289
243
|
throw new KernelError(msgPromise.content);
|
|
290
244
|
case 29:
|
|
291
|
-
|
|
245
|
+
_context3.next = 36;
|
|
292
246
|
break;
|
|
293
247
|
case 31:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (!
|
|
297
|
-
|
|
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
|
|
254
|
+
return _context3.abrupt("return", false);
|
|
301
255
|
case 35:
|
|
302
|
-
throw
|
|
256
|
+
throw _context3.t0;
|
|
303
257
|
case 36:
|
|
304
258
|
case "end":
|
|
305
|
-
return
|
|
259
|
+
return _context3.stop();
|
|
306
260
|
}
|
|
307
|
-
},
|
|
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(
|
|
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 =
|
|
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) {
|
|
@@ -54,6 +54,10 @@ export declare const FileCommands: {
|
|
|
54
54
|
id: string;
|
|
55
55
|
label: string;
|
|
56
56
|
};
|
|
57
|
+
UPLOAD: {
|
|
58
|
+
id: string;
|
|
59
|
+
label: string;
|
|
60
|
+
};
|
|
57
61
|
};
|
|
58
62
|
export declare const FileTreeContextMenuPath: MenuPath;
|
|
59
63
|
export declare const FileTreeContextMenuGroups: Record<string, MenuPath>;
|
|
@@ -67,6 +71,8 @@ export declare class FileCommandContribution implements CommandContribution, Men
|
|
|
67
71
|
fileView: FileView;
|
|
68
72
|
lastAction: 'COPY' | 'CUT';
|
|
69
73
|
lastActionNode: FileStatNode;
|
|
74
|
+
allowDownload: boolean;
|
|
75
|
+
allowUpload: boolean;
|
|
70
76
|
constructor(viewManager: ViewManager);
|
|
71
77
|
registerMenus(menu: MenuRegistry): void;
|
|
72
78
|
registerCommands(command: CommandRegistry): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-command.d.ts","sourceRoot":"","sources":["../../src/file/file-command.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EACV,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACL,mBAAmB,EACnB,YAAY,EAEZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EAEb,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-command.d.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AAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAkOhD,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI;CAQ7D"}
|
package/es/file/file-command.js
CHANGED
|
@@ -20,7 +20,6 @@ import { ContentsManager } from '@difizen/libro-kernel';
|
|
|
20
20
|
import { ViewManager, ConfigurationService } from '@difizen/mana-app';
|
|
21
21
|
import { CommandContribution, FileStatNode, inject, MenuContribution, ModalService, OpenerService, singleton, ToolbarContribution, URI } from '@difizen/mana-app';
|
|
22
22
|
import { message, Modal } from 'antd';
|
|
23
|
-
import { LibroConfigAllowDownload } from "../config/index.js";
|
|
24
23
|
import { FileCreateModal } from "./file-create-modal.js";
|
|
25
24
|
import { FileDirCreateModal } from "./file-createdir-modal.js";
|
|
26
25
|
import { FileRenameModal } from "./file-rename-modal.js";
|
|
@@ -77,6 +76,10 @@ export var FileCommands = {
|
|
|
77
76
|
DOWNLOAD: {
|
|
78
77
|
id: 'fileTree.command.download',
|
|
79
78
|
label: '下载'
|
|
79
|
+
},
|
|
80
|
+
UPLOAD: {
|
|
81
|
+
id: 'fileTree.command.upload',
|
|
82
|
+
label: '上传'
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
export var FileTreeContextMenuPath = ['file-tree-context-menu'];
|
|
@@ -101,6 +104,8 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
101
104
|
this.fileView = void 0;
|
|
102
105
|
this.lastAction = void 0;
|
|
103
106
|
this.lastActionNode = void 0;
|
|
107
|
+
this.allowDownload = false;
|
|
108
|
+
this.allowUpload = false;
|
|
104
109
|
this.viewManager = viewManager;
|
|
105
110
|
this.viewManager.getOrCreateView(FileView).then(function (view) {
|
|
106
111
|
_this.fileView = view;
|
|
@@ -171,6 +176,11 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
171
176
|
command: FileCommands.DOWNLOAD.id,
|
|
172
177
|
order: 'h'
|
|
173
178
|
});
|
|
179
|
+
menu.registerMenuAction(FileTreeContextMenuGroups['extra'], {
|
|
180
|
+
id: FileCommands.UPLOAD.id,
|
|
181
|
+
command: FileCommands.UPLOAD.id,
|
|
182
|
+
order: 'i'
|
|
183
|
+
});
|
|
174
184
|
}
|
|
175
185
|
}, {
|
|
176
186
|
key: "registerCommands",
|
|
@@ -480,6 +490,11 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
480
490
|
}
|
|
481
491
|
var path = data.uri.path.toString();
|
|
482
492
|
_this2.contentsManager.getDownloadUrl(path).then(function (url) {
|
|
493
|
+
var urlObj = new URL(url);
|
|
494
|
+
if (urlObj.origin !== location.origin) {
|
|
495
|
+
// not same origin
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
483
498
|
var element = document.createElement('a');
|
|
484
499
|
element.href = url;
|
|
485
500
|
element.download = '';
|
|
@@ -491,7 +506,35 @@ export var FileCommandContribution = (_dec = singleton({
|
|
|
491
506
|
}).catch(console.error);
|
|
492
507
|
},
|
|
493
508
|
isVisible: function isVisible(data) {
|
|
494
|
-
return
|
|
509
|
+
return _this2.allowDownload && FileStatNode.is(data) && data.fileStat.isFile;
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
command.registerCommand(FileCommands.UPLOAD, {
|
|
513
|
+
execute: function execute(data, view) {
|
|
514
|
+
if (!_this2.allowUpload) {
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
if (!view || !(view instanceof FileView)) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (!data || data instanceof FileView) {
|
|
521
|
+
return view.uploadSubmit();
|
|
522
|
+
}
|
|
523
|
+
if (FileStatNode.is(data) && data.fileStat.isDirectory) {
|
|
524
|
+
return view.uploadSubmit(data.uri.path.toString());
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
isVisible: function isVisible(data, view) {
|
|
528
|
+
if (!_this2.allowUpload) {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
if (!view || !(view instanceof FileView)) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
if (!data || data instanceof FileView) {
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
return FileStatNode.is(data) && data.fileStat.isDirectory;
|
|
495
538
|
}
|
|
496
539
|
});
|
|
497
540
|
}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import { ContentsManager } from '@difizen/libro-kernel';
|
|
2
|
+
import type { IContentsModel } from '@difizen/libro-kernel';
|
|
1
3
|
import type { TreeNode } from '@difizen/mana-app';
|
|
2
4
|
import { FileTreeModel, FileTreeView, LabelProvider, TreeDecoratorService, TreeProps, TreeViewDecorator, CommandRegistry, OpenerService, SelectionService } from '@difizen/mana-app';
|
|
3
5
|
import React from 'react';
|
|
4
6
|
import './index.less';
|
|
5
7
|
export declare class FileView extends FileTreeView {
|
|
6
8
|
protected openService: OpenerService;
|
|
9
|
+
protected contentsManager: ContentsManager;
|
|
7
10
|
protected command: CommandRegistry;
|
|
11
|
+
uploadInput?: HTMLInputElement;
|
|
8
12
|
id: string;
|
|
9
13
|
className: string;
|
|
10
14
|
constructor(props: TreeProps, model: FileTreeModel, treeViewDecorator: TreeViewDecorator, selectionService: SelectionService, labelProvider: LabelProvider, decoratorService: TreeDecoratorService);
|
|
15
|
+
onViewMount(): void;
|
|
16
|
+
uploadSubmit: (basePath?: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Perform the actual upload.
|
|
19
|
+
*/
|
|
20
|
+
protected doUpload(file: File, basePath: string): Promise<IContentsModel>;
|
|
21
|
+
onInputChanged: () => void;
|
|
22
|
+
onInputClicked: () => void;
|
|
11
23
|
openNode: (treeNode: TreeNode) => Promise<void>;
|
|
12
24
|
handleClickEvent(node: TreeNode | undefined, event: React.MouseEvent<HTMLElement>): void;
|
|
13
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/file/file-view/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,E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