@difizen/libro-lab 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/es/image-viewer/index.d.ts +3 -0
  2. package/es/image-viewer/index.d.ts.map +1 -0
  3. package/es/image-viewer/index.js +2 -0
  4. package/es/image-viewer/index.less +3 -0
  5. package/es/image-viewer/module.d.ts +3 -0
  6. package/es/image-viewer/module.d.ts.map +1 -0
  7. package/es/image-viewer/module.js +4 -0
  8. package/es/image-viewer/open-handler.d.ts +11 -0
  9. package/es/image-viewer/open-handler.d.ts.map +1 -0
  10. package/es/image-viewer/open-handler.js +106 -0
  11. package/es/image-viewer/protocol.d.ts +10 -0
  12. package/es/image-viewer/protocol.d.ts.map +1 -0
  13. package/es/image-viewer/protocol.js +27 -0
  14. package/es/image-viewer/viewer.d.ts +29 -0
  15. package/es/image-viewer/viewer.d.ts.map +1 -0
  16. package/es/image-viewer/viewer.js +185 -0
  17. package/es/index.d.ts +10 -0
  18. package/es/index.d.ts.map +1 -1
  19. package/es/index.js +11 -1
  20. package/es/layout/brand/{index.d.ts → brand.d.ts} +1 -1
  21. package/es/layout/brand/{index.d.ts.map → brand.d.ts.map} +1 -1
  22. package/es/layout/index.d.ts +8 -0
  23. package/es/layout/index.d.ts.map +1 -1
  24. package/es/layout/index.js +9 -1
  25. package/es/layout/layout.d.ts +1 -1
  26. package/es/layout/layout.d.ts.map +1 -1
  27. package/es/layout/layout.js +2 -2
  28. package/es/layout/module.js +1 -1
  29. package/es/menu/index.d.ts +5 -0
  30. package/es/menu/index.d.ts.map +1 -0
  31. package/es/menu/index.js +4 -0
  32. package/es/module.d.ts.map +1 -1
  33. package/es/module.js +2 -1
  34. package/es/toc/index.d.ts +3 -0
  35. package/es/toc/index.d.ts.map +1 -0
  36. package/es/toc/index.js +2 -0
  37. package/es/welcome/index.d.ts +2 -12
  38. package/es/welcome/index.d.ts.map +1 -1
  39. package/es/welcome/index.js +2 -70
  40. package/es/welcome/welcome-view.d.ts +13 -0
  41. package/es/welcome/welcome-view.d.ts.map +1 -0
  42. package/es/welcome/welcome-view.js +70 -0
  43. package/package.json +12 -9
  44. package/src/image-viewer/index.less +3 -0
  45. package/src/image-viewer/index.ts +2 -0
  46. package/src/image-viewer/module.ts +9 -0
  47. package/src/image-viewer/open-handler.ts +47 -0
  48. package/src/image-viewer/protocol.ts +43 -0
  49. package/src/image-viewer/viewer.tsx +131 -0
  50. package/src/index.ts +10 -0
  51. package/src/layout/index.tsx +8 -0
  52. package/src/layout/layout.tsx +3 -3
  53. package/src/layout/module.ts +1 -1
  54. package/src/menu/index.ts +4 -0
  55. package/src/module.tsx +2 -0
  56. package/src/toc/index.ts +2 -0
  57. package/src/welcome/index.ts +2 -0
  58. /package/es/layout/brand/{index.js → brand.js} +0 -0
  59. /package/src/layout/brand/{index.tsx → brand.tsx} +0 -0
  60. /package/src/welcome/{index.tsx → welcome-view.tsx} +0 -0
package/es/module.js CHANGED
@@ -4,6 +4,7 @@ import { TerminalModule } from '@difizen/libro-terminal';
4
4
  import { ManaModule, createSlotPreference, RootSlotId, SideTabView, createViewPreference, HeaderArea } from '@difizen/mana-app';
5
5
  import { LabConfigAppContribution } from "./config/config-contribution.js";
6
6
  import { GithubLinkView } from "./github-link/index.js";
7
+ import { ImageViewerModule } from "./image-viewer/index.js";
7
8
  import { KernelManagerView } from "./kernel-manager/index.js";
8
9
  import { LibroLabApp } from "./lab-app.js";
9
10
  import { ContentBottomTabView } from "./layout/content-bottom-tab-view.js";
@@ -60,4 +61,4 @@ export var LibroLabModule = ManaModule.create().register(LibroLabApp, LibroLabLa
60
61
  reveal: true,
61
62
  order: 'welcome'
62
63
  }
63
- }), EntryPointView).dependOn(LibroJupyterModule, LibroLabLayoutModule, LibroLabHeaderMenuModule, LibroLabTocModule, LibroPromptCellModule, TerminalModule);
64
+ }), EntryPointView).dependOn(LibroJupyterModule, LibroLabLayoutModule, LibroLabHeaderMenuModule, LibroLabTocModule, LibroPromptCellModule, TerminalModule, ImageViewerModule);
@@ -0,0 +1,3 @@
1
+ export * from './libro-toc-panel-view.js';
2
+ export * from './module.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/toc/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./libro-toc-panel-view.js";
2
+ export * from "./module.js";
@@ -1,13 +1,3 @@
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
- }
1
+ export * from './welcome-view.js';
2
+ export * from './entry-point-view.js';
13
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/welcome/index.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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/welcome/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC"}
@@ -1,70 +1,2 @@
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);
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",
3
+ "version": "0.1.5",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "libro",
@@ -33,19 +33,22 @@
33
33
  "src"
34
34
  ],
35
35
  "dependencies": {
36
+ "@ant-design/icons": "^5.1.0",
37
+ "@difizen/libro-core": "^0.1.5",
38
+ "@difizen/libro-jupyter": "^0.1.5",
39
+ "@difizen/libro-kernel": "^0.1.5",
40
+ "@difizen/libro-prompt-cell": "^0.1.5",
41
+ "@difizen/libro-terminal": "^0.1.5",
42
+ "@difizen/libro-toc": "^0.1.5",
36
43
  "@difizen/mana-app": "latest",
37
44
  "@difizen/mana-react": "latest",
38
- "@difizen/libro-jupyter": "^0.1.3",
39
- "@difizen/libro-toc": "^0.1.3",
40
- "@difizen/libro-prompt-cell": "^0.1.3",
41
- "@difizen/libro-terminal": "^0.1.3",
42
- "@ant-design/icons": "^5.1.0",
43
45
  "classnames": "^2.3.2",
44
- "uuid": "^9.0.0"
46
+ "uuid": "^9.0.0",
47
+ "viewerjs": "^1.11.6"
45
48
  },
46
49
  "peerDependencies": {
47
- "react": "^18.2.0",
48
- "antd": "^5.8.6"
50
+ "antd": "^5.8.6",
51
+ "react": "^18.2.0"
49
52
  },
50
53
  "devDependencies": {
51
54
  "@types/react": "^18.2.25",
@@ -0,0 +1,3 @@
1
+ .libro-lab-image-viewer {
2
+ background: var(--mana-color-bg-container);
3
+ }
@@ -0,0 +1,2 @@
1
+ export * from './module.js';
2
+ export * from './viewer.js';
@@ -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
+ });
@@ -0,0 +1,131 @@
1
+ import { ContentsManager } from '@difizen/libro-kernel';
2
+ import type { NavigatableView } from '@difizen/mana-app';
3
+ import { DisposableCollection } from '@difizen/mana-app';
4
+ import {
5
+ BaseView,
6
+ inject,
7
+ LabelProvider,
8
+ prop,
9
+ transient,
10
+ URI as VScodeURI,
11
+ URIIconReference,
12
+ useInject,
13
+ view,
14
+ ViewInstance,
15
+ ViewOption,
16
+ Deferred,
17
+ URI,
18
+ CommandRegistry,
19
+ } from '@difizen/mana-app';
20
+ import { Spin } from 'antd';
21
+ import { createRef, forwardRef, useEffect, useRef } from 'react';
22
+ import Viewer from 'viewerjs';
23
+ import './index.less';
24
+ import 'viewerjs/dist/viewer.css';
25
+
26
+ export function ImageViewer() {
27
+ const instance = useInject<NavigatableImageViewerView>(ViewInstance);
28
+ const ref = useRef<HTMLImageElement>(null);
29
+ const content = instance.content;
30
+ useEffect(() => {
31
+ if (ref && ref.current) {
32
+ new Viewer(ref.current, {
33
+ toolbar: {
34
+ prev: 0,
35
+ next: 0,
36
+ zoomIn: 4,
37
+ zoomOut: 4,
38
+ oneToOne: 4,
39
+ reset: 4,
40
+ play: {
41
+ show: 4,
42
+ size: 'large',
43
+ },
44
+ rotateLeft: 4,
45
+ rotateRight: 4,
46
+ flipHorizontal: 4,
47
+ flipVertical: 4,
48
+ },
49
+ });
50
+ }
51
+ }, [content, ref]);
52
+ if (!content) {
53
+ return null;
54
+ }
55
+ return <img ref={ref} src={`data:image/png;base64,${content}`} />;
56
+ }
57
+
58
+ export const NavigatableImageViewerComponent = forwardRef<HTMLDivElement>(
59
+ function LibroEditorComponent(props, ref) {
60
+ const instance = useInject<NavigatableImageViewerView>(ViewInstance);
61
+ const content = instance.content;
62
+ return (
63
+ <Spin spinning={!content}>
64
+ <div className="libro-lab-image-viewer" ref={ref}>
65
+ {content && <ImageViewer />}
66
+ </div>
67
+ </Spin>
68
+ );
69
+ },
70
+ );
71
+
72
+ export const NavigatableImageViewerViewFactoryId =
73
+ 'navigatable-image-viewer-view-factory';
74
+ @transient()
75
+ @view(NavigatableImageViewerViewFactoryId)
76
+ export class NavigatableImageViewerView extends BaseView implements NavigatableView {
77
+ @inject(CommandRegistry) commandRegistry: CommandRegistry;
78
+ @inject(ContentsManager) contentsManager: ContentsManager;
79
+
80
+ protected readonly toDisposeOnAutoSave = new DisposableCollection();
81
+
82
+ override view = NavigatableImageViewerComponent;
83
+
84
+ codeRef = createRef<HTMLDivElement>();
85
+
86
+ @prop() filePath?: string;
87
+ @prop() content?: string;
88
+
89
+ protected defer = new Deferred<void>();
90
+
91
+ get ready() {
92
+ return this.defer.promise;
93
+ }
94
+
95
+ constructor(
96
+ @inject(ViewOption) options: { path: string },
97
+ @inject(LabelProvider) labelProvider: LabelProvider,
98
+ ) {
99
+ super();
100
+ this.filePath = options.path;
101
+ this.title.caption = options.path;
102
+ const uri = new URI(options.path);
103
+ const uriRef = URIIconReference.create('file', new VScodeURI(options.path));
104
+ const iconClass = labelProvider.getIcon(uriRef);
105
+ this.title.icon = <div className={iconClass} />;
106
+ this.title.label = uri.displayName;
107
+ }
108
+
109
+ getFileContent = async () => {
110
+ if (this.filePath) {
111
+ const content = await this.contentsManager.get(this.filePath, {
112
+ content: true,
113
+ format: 'base64',
114
+ });
115
+ this.content = content.content;
116
+ }
117
+ };
118
+
119
+ override async onViewMount(): Promise<void> {
120
+ this.getFileContent();
121
+ }
122
+
123
+ getResourceUri(): URI | undefined {
124
+ return new URI(this.filePath);
125
+ }
126
+
127
+ createMoveToUri(resourceUri: URI): URI | undefined {
128
+ this.filePath = resourceUri.path.toString();
129
+ return resourceUri;
130
+ }
131
+ }
package/src/index.ts CHANGED
@@ -1 +1,11 @@
1
1
  export * from './module.js';
2
+ export * from './lab-app.js';
3
+ export * from './github-link/index.js';
4
+ export * from './config/index.js';
5
+ export * from './layout/index.js';
6
+ export * from './menu/index.js';
7
+ export * from './toc/index.js';
8
+ export * from './welcome/index.js';
9
+ export * from './kernel-manager/index.js';
10
+ export * from './common/index.js';
11
+ export * from './image-viewer/index.js';
@@ -1,4 +1,12 @@
1
1
  export * from './protocol.js';
2
2
  export * from './module.js';
3
3
  export * from './layout.js';
4
+ export * from './layout-service.js';
5
+ export * from './saveable-tab-view.js';
4
6
  export * from './footer/footer-view.js';
7
+ export * from './footer/status-footer-view.js';
8
+ export * from './footer/current-file-footer-view.js';
9
+ export * from './brand/brand.js';
10
+ export * from './main.js';
11
+ export * from './container.js';
12
+ export * from './content-bottom-tab-view.js';
@@ -11,8 +11,8 @@ import type { VisibilityMap } from './layout-service.js';
11
11
  import { LayoutService } from './layout-service.js';
12
12
  import { LibroLabLayoutSlots } from './protocol.js';
13
13
 
14
- export const LibroLabLayoutContainerComponent = forwardRef(
15
- function LibroLabLayoutContainerComponent() {
14
+ export const LibroLabLayoutComponent = forwardRef(
15
+ function LibroLabLayoutComponent() {
16
16
  const layoutService = useInject(LayoutService);
17
17
 
18
18
  return (
@@ -46,7 +46,7 @@ export const LibroLabLayoutContainerComponent = forwardRef(
46
46
  @singleton()
47
47
  @view('libro-lab-layout')
48
48
  export class LibroLabLayoutView extends BaseView {
49
- override view = LibroLabLayoutContainerComponent;
49
+ override view = LibroLabLayoutComponent;
50
50
 
51
51
  @inject(LayoutService) layoutService: LayoutService;
52
52
 
@@ -6,7 +6,7 @@ import {
6
6
  ManaModule,
7
7
  } from '@difizen/mana-app';
8
8
 
9
- import { BrandView } from './brand/index.js';
9
+ import { BrandView } from './brand/brand.js';
10
10
  import { LibroLabLayoutContainerView } from './container.js';
11
11
  import { ContentBottomTabView } from './content-bottom-tab-view.js';
12
12
  import { LibroLabCurrentFileFooterView } from './footer/current-file-footer-view.js';
@@ -0,0 +1,4 @@
1
+ export * from './menu-bar-view.js';
2
+ export * from './menu-command.js';
3
+ export * from './menu-contribution.js';
4
+ export * from './module.js';
package/src/module.tsx CHANGED
@@ -12,6 +12,7 @@ import {
12
12
 
13
13
  import { LabConfigAppContribution } from './config/config-contribution.js';
14
14
  import { GithubLinkView } from './github-link/index.js';
15
+ import { ImageViewerModule } from './image-viewer/index.js';
15
16
  import { KernelManagerView } from './kernel-manager/index.js';
16
17
  import { LibroLabApp } from './lab-app.js';
17
18
  import { ContentBottomTabView } from './layout/content-bottom-tab-view.js';
@@ -98,4 +99,5 @@ export const LibroLabModule = ManaModule.create()
98
99
  LibroLabTocModule,
99
100
  LibroPromptCellModule,
100
101
  TerminalModule,
102
+ ImageViewerModule,
101
103
  );
@@ -0,0 +1,2 @@
1
+ export * from './libro-toc-panel-view.js';
2
+ export * from './module.js';
@@ -0,0 +1,2 @@
1
+ export * from './welcome-view.js';
2
+ export * from './entry-point-view.js';
File without changes
File without changes
File without changes