@difizen/libro-lab 0.1.4 → 0.1.6
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/editor-viewer/code-editor-open-handler.d.ts +12 -0
- package/es/editor-viewer/code-editor-open-handler.d.ts.map +1 -0
- package/es/editor-viewer/code-editor-open-handler.js +101 -0
- package/es/editor-viewer/code-editor-viewer.d.ts +38 -0
- package/es/editor-viewer/code-editor-viewer.d.ts.map +1 -0
- package/es/editor-viewer/code-editor-viewer.js +235 -0
- package/es/editor-viewer/index.d.ts +3 -0
- package/es/editor-viewer/index.d.ts.map +1 -0
- package/es/editor-viewer/index.js +2 -0
- package/es/editor-viewer/index.less +3 -0
- package/es/editor-viewer/module.d.ts +3 -0
- package/es/editor-viewer/module.d.ts.map +1 -0
- package/es/editor-viewer/module.js +4 -0
- package/es/editor-viewer/protocol.d.ts +7 -0
- package/es/editor-viewer/protocol.d.ts.map +1 -0
- package/es/editor-viewer/protocol.js +1 -0
- package/es/image-viewer/index.d.ts +3 -0
- package/es/image-viewer/index.d.ts.map +1 -0
- package/es/image-viewer/index.js +2 -0
- package/es/image-viewer/index.less +3 -0
- package/es/image-viewer/module.d.ts +3 -0
- package/es/image-viewer/module.d.ts.map +1 -0
- package/es/image-viewer/module.js +4 -0
- package/es/image-viewer/open-handler.d.ts +11 -0
- package/es/image-viewer/open-handler.d.ts.map +1 -0
- package/es/image-viewer/open-handler.js +106 -0
- package/es/image-viewer/protocol.d.ts +10 -0
- package/es/image-viewer/protocol.d.ts.map +1 -0
- package/es/image-viewer/protocol.js +27 -0
- package/es/image-viewer/viewer.d.ts +29 -0
- package/es/image-viewer/viewer.d.ts.map +1 -0
- package/es/image-viewer/viewer.js +185 -0
- package/es/index.d.ts +11 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +12 -1
- package/es/layout/brand/{index.d.ts → brand.d.ts} +1 -1
- package/es/layout/brand/{index.d.ts.map → brand.d.ts.map} +1 -1
- package/es/layout/index.d.ts +8 -0
- package/es/layout/index.d.ts.map +1 -1
- package/es/layout/index.js +9 -1
- package/es/layout/layout.d.ts +1 -1
- package/es/layout/layout.d.ts.map +1 -1
- package/es/layout/layout.js +2 -2
- package/es/layout/module.js +1 -1
- package/es/menu/index.d.ts +5 -0
- package/es/menu/index.d.ts.map +1 -0
- package/es/menu/index.js +4 -0
- package/es/module.d.ts.map +1 -1
- package/es/module.js +3 -1
- package/es/toc/index.d.ts +3 -0
- package/es/toc/index.d.ts.map +1 -0
- package/es/toc/index.js +2 -0
- package/es/welcome/index.d.ts +2 -12
- package/es/welcome/index.d.ts.map +1 -1
- package/es/welcome/index.js +2 -70
- package/es/welcome/welcome-view.d.ts +13 -0
- package/es/welcome/welcome-view.d.ts.map +1 -0
- package/es/welcome/welcome-view.js +70 -0
- package/package.json +13 -9
- package/src/editor-viewer/code-editor-open-handler.ts +42 -0
- package/src/editor-viewer/code-editor-viewer.tsx +183 -0
- package/src/editor-viewer/index.less +3 -0
- package/src/editor-viewer/index.ts +2 -0
- package/src/editor-viewer/module.ts +8 -0
- package/src/editor-viewer/protocol.ts +7 -0
- package/src/image-viewer/index.less +3 -0
- package/src/image-viewer/index.ts +2 -0
- package/src/image-viewer/module.ts +9 -0
- package/src/image-viewer/open-handler.ts +47 -0
- package/src/image-viewer/protocol.ts +43 -0
- package/src/image-viewer/viewer.tsx +131 -0
- package/src/index.ts +11 -0
- package/src/layout/index.tsx +8 -0
- package/src/layout/layout.tsx +3 -3
- package/src/layout/module.ts +1 -1
- package/src/menu/index.ts +4 -0
- package/src/module.tsx +4 -0
- package/src/toc/index.ts +2 -0
- package/src/welcome/index.ts +2 -0
- /package/es/layout/brand/{index.js → brand.js} +0 -0
- /package/src/layout/brand/{index.tsx → brand.tsx} +0 -0
- /package/src/welcome/{index.tsx → welcome-view.tsx} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/welcome/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/welcome/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
|
package/es/welcome/index.js
CHANGED
|
@@ -1,70 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
9
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
12
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
|
-
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; } }
|
|
14
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
15
|
-
import { ServerConnection } from '@difizen/libro-jupyter';
|
|
16
|
-
import { inject, singleton, useInject, view, ViewInstance, ViewManager, ViewRender } from '@difizen/mana-app';
|
|
17
|
-
import { BaseView } from '@difizen/mana-app';
|
|
18
|
-
import { forwardRef } from 'react';
|
|
19
|
-
import { LayoutService } from "../layout/layout-service.js";
|
|
20
|
-
import { EntryPointView } from "./entry-point-view.js";
|
|
21
|
-
import "./index.less";
|
|
22
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
export var WelcomeComponent = /*#__PURE__*/forwardRef(function WelcomeComponent() {
|
|
25
|
-
var instance = useInject(ViewInstance);
|
|
26
|
-
var layoutService = useInject(LayoutService);
|
|
27
|
-
var serverConnection = useInject(ServerConnection);
|
|
28
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
29
|
-
className: "libro-lab-welcome-page",
|
|
30
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
31
|
-
className: "libro-lab-welcome-page-title",
|
|
32
|
-
children: "\u6B22\u8FCE\u4F7F\u7528 Notebook \u5DE5\u4F5C\u53F0 \uD83C\uDF89\uD83C\uDF89"
|
|
33
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
34
|
-
className: "libro-lab-welcome-page-server-info",
|
|
35
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
36
|
-
className: "libro-lab-welcome-page-server-info-title",
|
|
37
|
-
children: "\u670D\u52A1\u8FDE\u63A5\u4FE1\u606F"
|
|
38
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
39
|
-
className: "libro-lab-welcome-page-server-info-item",
|
|
40
|
-
children: ["BaseURL: ", "".concat(serverConnection.settings.baseUrl)]
|
|
41
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
42
|
-
className: "libro-lab-welcome-page-server-info-item",
|
|
43
|
-
children: ["WsURL: ", "".concat(serverConnection.settings.wsUrl)]
|
|
44
|
-
})]
|
|
45
|
-
}), layoutService.serverSatus === 'success' && /*#__PURE__*/_jsx(ViewRender, {
|
|
46
|
-
view: instance.entryPointView
|
|
47
|
-
})]
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
export var WelcomeView = (_dec = singleton(), _dec2 = view('welcome-view'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_BaseView) {
|
|
51
|
-
_inherits(WelcomeView, _BaseView);
|
|
52
|
-
var _super = _createSuper(WelcomeView);
|
|
53
|
-
function WelcomeView(viewManager) {
|
|
54
|
-
var _this;
|
|
55
|
-
_classCallCheck(this, WelcomeView);
|
|
56
|
-
_this = _super.call(this);
|
|
57
|
-
_this.view = WelcomeComponent;
|
|
58
|
-
_this.title.icon = '🙌 ';
|
|
59
|
-
_this.title.label = '欢迎使用';
|
|
60
|
-
_this.title.closable = false;
|
|
61
|
-
_this.viewManager = viewManager;
|
|
62
|
-
_this.viewManager.getOrCreateView(EntryPointView).then(function (entryPointView) {
|
|
63
|
-
_this.entryPointView = entryPointView;
|
|
64
|
-
return;
|
|
65
|
-
}).catch(console.error);
|
|
66
|
-
return _this;
|
|
67
|
-
}
|
|
68
|
-
WelcomeView = inject(ViewManager)(WelcomeView, undefined, 0) || WelcomeView;
|
|
69
|
-
return _createClass(WelcomeView);
|
|
70
|
-
}(BaseView)) || _class) || _class);
|
|
1
|
+
export * from "./welcome-view.js";
|
|
2
|
+
export * from "./entry-point-view.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
3
|
+
import { BaseView } from '@difizen/mana-app';
|
|
4
|
+
import { EntryPointView } from './entry-point-view.js';
|
|
5
|
+
import './index.less';
|
|
6
|
+
export declare const WelcomeComponent: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
7
|
+
export declare class WelcomeView extends BaseView {
|
|
8
|
+
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
9
|
+
viewManager: ViewManager;
|
|
10
|
+
entryPointView: EntryPointView;
|
|
11
|
+
constructor(viewManager: ViewManager);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=welcome-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"welcome-view.d.ts","sourceRoot":"","sources":["../../src/welcome/welcome-view.tsx"],"names":[],"mappings":";AACA,OAAO,EAML,WAAW,EAEZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,cAAc,CAAC;AAEtB,eAAO,MAAM,gBAAgB,mFAqB3B,CAAC;AAEH,qBAEa,WAAY,SAAQ,QAAQ;IAC9B,IAAI,oFAAoB;IACjC,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;gBACE,WAAW,EAAE,WAAW;CAc1D"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _class;
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
9
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
12
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
|
+
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; } }
|
|
14
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
15
|
+
import { ServerConnection } from '@difizen/libro-jupyter';
|
|
16
|
+
import { inject, singleton, useInject, view, ViewInstance, ViewManager, ViewRender } from '@difizen/mana-app';
|
|
17
|
+
import { BaseView } from '@difizen/mana-app';
|
|
18
|
+
import { forwardRef } from 'react';
|
|
19
|
+
import { LayoutService } from "../layout/layout-service.js";
|
|
20
|
+
import { EntryPointView } from "./entry-point-view.js";
|
|
21
|
+
import "./index.less";
|
|
22
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
export var WelcomeComponent = /*#__PURE__*/forwardRef(function WelcomeComponent() {
|
|
25
|
+
var instance = useInject(ViewInstance);
|
|
26
|
+
var layoutService = useInject(LayoutService);
|
|
27
|
+
var serverConnection = useInject(ServerConnection);
|
|
28
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
29
|
+
className: "libro-lab-welcome-page",
|
|
30
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
31
|
+
className: "libro-lab-welcome-page-title",
|
|
32
|
+
children: "\u6B22\u8FCE\u4F7F\u7528 Notebook \u5DE5\u4F5C\u53F0 \uD83C\uDF89\uD83C\uDF89"
|
|
33
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
34
|
+
className: "libro-lab-welcome-page-server-info",
|
|
35
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
36
|
+
className: "libro-lab-welcome-page-server-info-title",
|
|
37
|
+
children: "\u670D\u52A1\u8FDE\u63A5\u4FE1\u606F"
|
|
38
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
39
|
+
className: "libro-lab-welcome-page-server-info-item",
|
|
40
|
+
children: ["BaseURL: ", "".concat(serverConnection.settings.baseUrl)]
|
|
41
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
42
|
+
className: "libro-lab-welcome-page-server-info-item",
|
|
43
|
+
children: ["WsURL: ", "".concat(serverConnection.settings.wsUrl)]
|
|
44
|
+
})]
|
|
45
|
+
}), layoutService.serverSatus === 'success' && /*#__PURE__*/_jsx(ViewRender, {
|
|
46
|
+
view: instance.entryPointView
|
|
47
|
+
})]
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
export var WelcomeView = (_dec = singleton(), _dec2 = view('welcome-view'), _dec(_class = _dec2(_class = /*#__PURE__*/function (_BaseView) {
|
|
51
|
+
_inherits(WelcomeView, _BaseView);
|
|
52
|
+
var _super = _createSuper(WelcomeView);
|
|
53
|
+
function WelcomeView(viewManager) {
|
|
54
|
+
var _this;
|
|
55
|
+
_classCallCheck(this, WelcomeView);
|
|
56
|
+
_this = _super.call(this);
|
|
57
|
+
_this.view = WelcomeComponent;
|
|
58
|
+
_this.title.icon = '🙌 ';
|
|
59
|
+
_this.title.label = '欢迎使用';
|
|
60
|
+
_this.title.closable = false;
|
|
61
|
+
_this.viewManager = viewManager;
|
|
62
|
+
_this.viewManager.getOrCreateView(EntryPointView).then(function (entryPointView) {
|
|
63
|
+
_this.entryPointView = entryPointView;
|
|
64
|
+
return;
|
|
65
|
+
}).catch(console.error);
|
|
66
|
+
return _this;
|
|
67
|
+
}
|
|
68
|
+
WelcomeView = inject(ViewManager)(WelcomeView, undefined, 0) || WelcomeView;
|
|
69
|
+
return _createClass(WelcomeView);
|
|
70
|
+
}(BaseView)) || _class) || _class);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-lab",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -33,19 +33,23 @@
|
|
|
33
33
|
"src"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"@ant-design/icons": "^5.1.0",
|
|
37
|
+
"@difizen/libro-core": "^0.1.6",
|
|
38
|
+
"@difizen/libro-jupyter": "^0.1.6",
|
|
39
|
+
"@difizen/libro-kernel": "^0.1.6",
|
|
40
|
+
"@difizen/libro-prompt-cell": "^0.1.6",
|
|
41
|
+
"@difizen/libro-terminal": "^0.1.6",
|
|
42
|
+
"@difizen/libro-toc": "^0.1.6",
|
|
43
|
+
"@difizen/libro-cofine-editor-core": "^0.1.6",
|
|
36
44
|
"@difizen/mana-app": "latest",
|
|
37
45
|
"@difizen/mana-react": "latest",
|
|
38
|
-
"@difizen/libro-jupyter": "^0.1.4",
|
|
39
|
-
"@difizen/libro-toc": "^0.1.4",
|
|
40
|
-
"@difizen/libro-prompt-cell": "^0.1.4",
|
|
41
|
-
"@difizen/libro-terminal": "^0.1.4",
|
|
42
|
-
"@ant-design/icons": "^5.1.0",
|
|
43
46
|
"classnames": "^2.3.2",
|
|
44
|
-
"uuid": "^9.0.0"
|
|
47
|
+
"uuid": "^9.0.0",
|
|
48
|
+
"viewerjs": "^1.11.6"
|
|
45
49
|
},
|
|
46
50
|
"peerDependencies": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
51
|
+
"antd": "^5.8.6",
|
|
52
|
+
"react": "^18.2.0"
|
|
49
53
|
},
|
|
50
54
|
"devDependencies": {
|
|
51
55
|
"@types/react": "^18.2.25",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LibroJupyterConfiguration } from '@difizen/libro-jupyter';
|
|
2
|
+
import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
|
|
3
|
+
import { ConfigurationService, inject } from '@difizen/mana-app';
|
|
4
|
+
import { Priority } from '@difizen/mana-app';
|
|
5
|
+
import { NavigatableViewOpenHandler, OpenHandler, singleton } from '@difizen/mana-app';
|
|
6
|
+
|
|
7
|
+
import type { CodeEditorViewer } from './code-editor-viewer.js';
|
|
8
|
+
import { CodeEditorViewerFactory } from './protocol.js';
|
|
9
|
+
|
|
10
|
+
@singleton({ contrib: OpenHandler })
|
|
11
|
+
export class CodeEditorViewerOpenHandler extends NavigatableViewOpenHandler<CodeEditorViewer> {
|
|
12
|
+
@inject(ConfigurationService) protected configurationService: ConfigurationService;
|
|
13
|
+
|
|
14
|
+
id = CodeEditorViewerFactory;
|
|
15
|
+
|
|
16
|
+
canHandle(uri: URI, options?: ViewOpenHandlerOptions) {
|
|
17
|
+
if (
|
|
18
|
+
uri.scheme === 'file' &&
|
|
19
|
+
!['.tar', '.zip', '.7z', '.gz', 'rar'].includes(uri.path.ext)
|
|
20
|
+
) {
|
|
21
|
+
return 100;
|
|
22
|
+
}
|
|
23
|
+
return Priority.IDLE;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override async open(uri: URI, options: ViewOpenHandlerOptions = {}) {
|
|
27
|
+
const { viewOptions, ...extra } = options;
|
|
28
|
+
const slot = await this.configurationService.get(
|
|
29
|
+
LibroJupyterConfiguration['OpenSlot'],
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return super.open(uri, {
|
|
33
|
+
slot,
|
|
34
|
+
viewOptions: {
|
|
35
|
+
path: uri.path.toString(),
|
|
36
|
+
...viewOptions,
|
|
37
|
+
},
|
|
38
|
+
reveal: true,
|
|
39
|
+
...extra,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { EditorProvider, MonacoEnvironment } from '@difizen/libro-cofine-editor-core';
|
|
2
|
+
import type { LanguageSpec, MonacoEditorOptions } from '@difizen/libro-jupyter';
|
|
3
|
+
import { LibroConfigAutoSave } from '@difizen/libro-jupyter';
|
|
4
|
+
import { MonacoUri } from '@difizen/libro-jupyter';
|
|
5
|
+
import { JupyterFileService, LanguageSpecRegistry } from '@difizen/libro-jupyter';
|
|
6
|
+
import type { NavigatableView, Saveable } from '@difizen/mana-app';
|
|
7
|
+
import { ConfigurationService } from '@difizen/mana-app';
|
|
8
|
+
import { Disposable } from '@difizen/mana-app';
|
|
9
|
+
import {
|
|
10
|
+
DisposableCollection,
|
|
11
|
+
Emitter,
|
|
12
|
+
getOrigin,
|
|
13
|
+
inject,
|
|
14
|
+
LabelProvider,
|
|
15
|
+
prop,
|
|
16
|
+
URI,
|
|
17
|
+
URIIconReference,
|
|
18
|
+
ViewOption,
|
|
19
|
+
} from '@difizen/mana-app';
|
|
20
|
+
import { BaseView, transient, useInject, view, ViewInstance } from '@difizen/mana-app';
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import './index.less';
|
|
23
|
+
|
|
24
|
+
import type { EditorOption } from './protocol.js';
|
|
25
|
+
import { CodeEditorViewerFactory } from './protocol.js';
|
|
26
|
+
|
|
27
|
+
const EditorComponent: React.FC = () => {
|
|
28
|
+
const viewInstance = useInject<CodeEditorViewer>(ViewInstance);
|
|
29
|
+
return <div className="libro-lab-editor-viewer" ref={viewInstance.codeRef}></div>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type EditorType = ReturnType<EditorProvider['create']>;
|
|
33
|
+
export const LibroLabE2URIScheme = 'libro-lab-e2';
|
|
34
|
+
|
|
35
|
+
@transient()
|
|
36
|
+
@view(CodeEditorViewerFactory)
|
|
37
|
+
export class CodeEditorViewer extends BaseView implements NavigatableView, Saveable {
|
|
38
|
+
override view = EditorComponent;
|
|
39
|
+
|
|
40
|
+
codeRef = React.createRef<HTMLDivElement>();
|
|
41
|
+
|
|
42
|
+
protected e2Editor?: EditorType;
|
|
43
|
+
|
|
44
|
+
@prop()
|
|
45
|
+
dirty = false;
|
|
46
|
+
|
|
47
|
+
language = 'text';
|
|
48
|
+
|
|
49
|
+
value: string;
|
|
50
|
+
|
|
51
|
+
@prop() filePath?: string;
|
|
52
|
+
|
|
53
|
+
autoSaveDelay = 1000;
|
|
54
|
+
|
|
55
|
+
dirtyEmitter = new Emitter<void>();
|
|
56
|
+
|
|
57
|
+
languageSpecRegistry: LanguageSpecRegistry;
|
|
58
|
+
|
|
59
|
+
get onDirtyChanged() {
|
|
60
|
+
return this.dirtyEmitter.event;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
autoSave: 'on' | 'off' = 'off';
|
|
64
|
+
|
|
65
|
+
protected readonly toDisposeOnAutoSave = new DisposableCollection();
|
|
66
|
+
|
|
67
|
+
languageSpec?: LanguageSpec;
|
|
68
|
+
|
|
69
|
+
fileService: JupyterFileService;
|
|
70
|
+
|
|
71
|
+
constructor(
|
|
72
|
+
@inject(ViewOption)
|
|
73
|
+
options: EditorOption,
|
|
74
|
+
@inject(LabelProvider) labelProvider: LabelProvider,
|
|
75
|
+
@inject(JupyterFileService) fileService: JupyterFileService,
|
|
76
|
+
@inject(LanguageSpecRegistry)
|
|
77
|
+
languageSpecRegistry: LanguageSpecRegistry,
|
|
78
|
+
@inject(ConfigurationService) configurationService: ConfigurationService,
|
|
79
|
+
) {
|
|
80
|
+
super();
|
|
81
|
+
this.filePath = options.path;
|
|
82
|
+
this.title.caption = options.path;
|
|
83
|
+
const uri = new URI(options.path);
|
|
84
|
+
const uriRef = URIIconReference.create('file', new URI(options.path));
|
|
85
|
+
const iconClass = labelProvider.getIcon(uriRef);
|
|
86
|
+
this.fileService = fileService;
|
|
87
|
+
this.title.icon = <div className={iconClass} />;
|
|
88
|
+
this.title.label = uri.path.base;
|
|
89
|
+
this.languageSpecRegistry = languageSpecRegistry;
|
|
90
|
+
this.languageSpec = this.languageSpecRegistry.languageSpecs.find((item) =>
|
|
91
|
+
item.ext.includes(uri.path.ext),
|
|
92
|
+
);
|
|
93
|
+
configurationService
|
|
94
|
+
.get(LibroConfigAutoSave)
|
|
95
|
+
.then((value) => {
|
|
96
|
+
if (value) {
|
|
97
|
+
this.autoSave = 'on';
|
|
98
|
+
return;
|
|
99
|
+
} else {
|
|
100
|
+
this.autoSave = 'off';
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
.catch(() => {
|
|
105
|
+
//
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
override async onViewMount() {
|
|
110
|
+
if (!this.filePath) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const content = await getOrigin(this.fileService).read(this.filePath);
|
|
114
|
+
if (typeof content !== 'string' || !this.languageSpec) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (!this.codeRef || !this.codeRef.current) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
await MonacoEnvironment.init();
|
|
122
|
+
await this.languageSpec.beforeEditorInit?.();
|
|
123
|
+
const editorPorvider =
|
|
124
|
+
MonacoEnvironment.container.get<EditorProvider>(EditorProvider);
|
|
125
|
+
|
|
126
|
+
const uri = MonacoUri.from({
|
|
127
|
+
scheme: LibroLabE2URIScheme,
|
|
128
|
+
path: `${this.filePath}${this.languageSpec.ext[0]}`,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const options: MonacoEditorOptions = {
|
|
132
|
+
/**
|
|
133
|
+
* language ia an uri:
|
|
134
|
+
*/
|
|
135
|
+
theme: 'libro-light',
|
|
136
|
+
language: this.languageSpec.language,
|
|
137
|
+
uri,
|
|
138
|
+
value: content,
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
this.e2Editor = editorPorvider.create(this.codeRef.current, options);
|
|
142
|
+
this.toDispose.push(
|
|
143
|
+
getOrigin(this.e2Editor.codeEditor).onDidChangeModelContent(() => {
|
|
144
|
+
this.dirty = true;
|
|
145
|
+
if (this.autoSave === 'on') {
|
|
146
|
+
this.doAutoSave();
|
|
147
|
+
}
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
protected doAutoSave = () => {
|
|
153
|
+
this.toDisposeOnAutoSave.dispose();
|
|
154
|
+
if (!this.e2Editor) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const handle = window.setTimeout(async () => {
|
|
158
|
+
this.save();
|
|
159
|
+
}, this.autoSaveDelay);
|
|
160
|
+
this.toDisposeOnAutoSave.push(Disposable.create(() => window.clearTimeout(handle)));
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
save = async () => {
|
|
164
|
+
this.value = this.e2Editor?.codeEditor.getValue() || '';
|
|
165
|
+
await this.fileService.write(this.filePath!, this.value);
|
|
166
|
+
this.dirty = false;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
getResourceUri(): URI | undefined {
|
|
170
|
+
return new URI(this.filePath);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
createMoveToUri(resourceUri: URI): URI | undefined {
|
|
174
|
+
this.filePath = resourceUri.path.toString();
|
|
175
|
+
return resourceUri;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
override dispose(): void {
|
|
179
|
+
this.toDispose.dispose();
|
|
180
|
+
this.toDisposeOnAutoSave.dispose();
|
|
181
|
+
super.dispose();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { CodeEditorViewerOpenHandler } from './code-editor-open-handler.js';
|
|
4
|
+
import { CodeEditorViewer } from './code-editor-viewer.js';
|
|
5
|
+
|
|
6
|
+
export const CodeEditorViewerModule = ManaModule.create(
|
|
7
|
+
'CodeEditorViewerModule',
|
|
8
|
+
).register(CodeEditorViewer, CodeEditorViewerOpenHandler);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { ImageViewerOpenHandler } from './open-handler.js';
|
|
4
|
+
import { NavigatableImageViewerView } from './viewer.js';
|
|
5
|
+
|
|
6
|
+
export const ImageViewerModule = ManaModule.create('ImageViewerModule').register(
|
|
7
|
+
NavigatableImageViewerView,
|
|
8
|
+
ImageViewerOpenHandler,
|
|
9
|
+
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LibroJupyterConfiguration } from '@difizen/libro-jupyter';
|
|
2
|
+
import type { URI, ViewOpenHandlerOptions } from '@difizen/mana-app';
|
|
3
|
+
import { ConfigurationService, inject } from '@difizen/mana-app';
|
|
4
|
+
import {
|
|
5
|
+
NavigatableViewOpenHandler,
|
|
6
|
+
OpenHandler,
|
|
7
|
+
singleton,
|
|
8
|
+
Priority,
|
|
9
|
+
} from '@difizen/mana-app';
|
|
10
|
+
|
|
11
|
+
import { imageExtToTypes } from './protocol.js';
|
|
12
|
+
import { NavigatableImageViewerViewFactoryId } from './viewer.js';
|
|
13
|
+
import type { NavigatableImageViewerView } from './viewer.js';
|
|
14
|
+
|
|
15
|
+
@singleton({ contrib: OpenHandler })
|
|
16
|
+
export class ImageViewerOpenHandler extends NavigatableViewOpenHandler<NavigatableImageViewerView> {
|
|
17
|
+
@inject(ConfigurationService) protected configurationService: ConfigurationService;
|
|
18
|
+
|
|
19
|
+
id = NavigatableImageViewerViewFactoryId;
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
+
canHandle(uri: URI, _options?: ViewOpenHandlerOptions) {
|
|
23
|
+
if (uri.scheme === 'file') {
|
|
24
|
+
const ext = uri.path.ext;
|
|
25
|
+
if (imageExtToTypes.has(ext)) {
|
|
26
|
+
return 100;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return Priority.IDLE;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override async open(uri: URI, options: ViewOpenHandlerOptions = {}) {
|
|
33
|
+
const { viewOptions, ...extra } = options;
|
|
34
|
+
const slot = await this.configurationService.get(
|
|
35
|
+
LibroJupyterConfiguration['OpenSlot'],
|
|
36
|
+
);
|
|
37
|
+
return super.open(uri, {
|
|
38
|
+
slot,
|
|
39
|
+
viewOptions: {
|
|
40
|
+
path: uri.path.toString(),
|
|
41
|
+
...viewOptions,
|
|
42
|
+
},
|
|
43
|
+
reveal: true,
|
|
44
|
+
...extra,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ContentsFileFormat } from '@difizen/libro-kernel';
|
|
2
|
+
|
|
3
|
+
interface ImageFormat {
|
|
4
|
+
name: string;
|
|
5
|
+
extensions: string[];
|
|
6
|
+
format: ContentsFileFormat;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const imageFileTypes: ImageFormat[] = [
|
|
10
|
+
{
|
|
11
|
+
name: 'jpeg',
|
|
12
|
+
extensions: ['.jpg', '.jpeg'],
|
|
13
|
+
format: 'base64',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'gif',
|
|
17
|
+
extensions: ['.gif'],
|
|
18
|
+
format: 'base64',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'png',
|
|
22
|
+
extensions: ['.png'],
|
|
23
|
+
format: 'base64',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'bmp',
|
|
27
|
+
extensions: ['.bmp'],
|
|
28
|
+
format: 'base64',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'webp',
|
|
32
|
+
extensions: ['.webp'],
|
|
33
|
+
format: 'base64',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export const imageExtToTypes = new Map<string, ImageFormat>();
|
|
38
|
+
|
|
39
|
+
imageFileTypes.forEach((imageType) => {
|
|
40
|
+
imageType.extensions.forEach((ext) => {
|
|
41
|
+
imageExtToTypes.set(ext, imageType);
|
|
42
|
+
});
|
|
43
|
+
});
|