@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.
Files changed (82) hide show
  1. package/es/editor-viewer/code-editor-open-handler.d.ts +12 -0
  2. package/es/editor-viewer/code-editor-open-handler.d.ts.map +1 -0
  3. package/es/editor-viewer/code-editor-open-handler.js +101 -0
  4. package/es/editor-viewer/code-editor-viewer.d.ts +38 -0
  5. package/es/editor-viewer/code-editor-viewer.d.ts.map +1 -0
  6. package/es/editor-viewer/code-editor-viewer.js +235 -0
  7. package/es/editor-viewer/index.d.ts +3 -0
  8. package/es/editor-viewer/index.d.ts.map +1 -0
  9. package/es/editor-viewer/index.js +2 -0
  10. package/es/editor-viewer/index.less +3 -0
  11. package/es/editor-viewer/module.d.ts +3 -0
  12. package/es/editor-viewer/module.d.ts.map +1 -0
  13. package/es/editor-viewer/module.js +4 -0
  14. package/es/editor-viewer/protocol.d.ts +7 -0
  15. package/es/editor-viewer/protocol.d.ts.map +1 -0
  16. package/es/editor-viewer/protocol.js +1 -0
  17. package/es/image-viewer/index.d.ts +3 -0
  18. package/es/image-viewer/index.d.ts.map +1 -0
  19. package/es/image-viewer/index.js +2 -0
  20. package/es/image-viewer/index.less +3 -0
  21. package/es/image-viewer/module.d.ts +3 -0
  22. package/es/image-viewer/module.d.ts.map +1 -0
  23. package/es/image-viewer/module.js +4 -0
  24. package/es/image-viewer/open-handler.d.ts +11 -0
  25. package/es/image-viewer/open-handler.d.ts.map +1 -0
  26. package/es/image-viewer/open-handler.js +106 -0
  27. package/es/image-viewer/protocol.d.ts +10 -0
  28. package/es/image-viewer/protocol.d.ts.map +1 -0
  29. package/es/image-viewer/protocol.js +27 -0
  30. package/es/image-viewer/viewer.d.ts +29 -0
  31. package/es/image-viewer/viewer.d.ts.map +1 -0
  32. package/es/image-viewer/viewer.js +185 -0
  33. package/es/index.d.ts +11 -0
  34. package/es/index.d.ts.map +1 -1
  35. package/es/index.js +12 -1
  36. package/es/layout/brand/{index.d.ts → brand.d.ts} +1 -1
  37. package/es/layout/brand/{index.d.ts.map → brand.d.ts.map} +1 -1
  38. package/es/layout/index.d.ts +8 -0
  39. package/es/layout/index.d.ts.map +1 -1
  40. package/es/layout/index.js +9 -1
  41. package/es/layout/layout.d.ts +1 -1
  42. package/es/layout/layout.d.ts.map +1 -1
  43. package/es/layout/layout.js +2 -2
  44. package/es/layout/module.js +1 -1
  45. package/es/menu/index.d.ts +5 -0
  46. package/es/menu/index.d.ts.map +1 -0
  47. package/es/menu/index.js +4 -0
  48. package/es/module.d.ts.map +1 -1
  49. package/es/module.js +3 -1
  50. package/es/toc/index.d.ts +3 -0
  51. package/es/toc/index.d.ts.map +1 -0
  52. package/es/toc/index.js +2 -0
  53. package/es/welcome/index.d.ts +2 -12
  54. package/es/welcome/index.d.ts.map +1 -1
  55. package/es/welcome/index.js +2 -70
  56. package/es/welcome/welcome-view.d.ts +13 -0
  57. package/es/welcome/welcome-view.d.ts.map +1 -0
  58. package/es/welcome/welcome-view.js +70 -0
  59. package/package.json +13 -9
  60. package/src/editor-viewer/code-editor-open-handler.ts +42 -0
  61. package/src/editor-viewer/code-editor-viewer.tsx +183 -0
  62. package/src/editor-viewer/index.less +3 -0
  63. package/src/editor-viewer/index.ts +2 -0
  64. package/src/editor-viewer/module.ts +8 -0
  65. package/src/editor-viewer/protocol.ts +7 -0
  66. package/src/image-viewer/index.less +3 -0
  67. package/src/image-viewer/index.ts +2 -0
  68. package/src/image-viewer/module.ts +9 -0
  69. package/src/image-viewer/open-handler.ts +47 -0
  70. package/src/image-viewer/protocol.ts +43 -0
  71. package/src/image-viewer/viewer.tsx +131 -0
  72. package/src/index.ts +11 -0
  73. package/src/layout/index.tsx +8 -0
  74. package/src/layout/layout.tsx +3 -3
  75. package/src/layout/module.ts +1 -1
  76. package/src/menu/index.ts +4 -0
  77. package/src/module.tsx +4 -0
  78. package/src/toc/index.ts +2 -0
  79. package/src/welcome/index.ts +2 -0
  80. /package/es/layout/brand/{index.js → brand.js} +0 -0
  81. /package/src/layout/brand/{index.tsx → brand.tsx} +0 -0
  82. /package/src/welcome/{index.tsx → welcome-view.tsx} +0 -0
@@ -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,12 @@
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';
12
+ export * from './editor-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
@@ -11,7 +11,9 @@ import {
11
11
  } from '@difizen/mana-app';
12
12
 
13
13
  import { LabConfigAppContribution } from './config/config-contribution.js';
14
+ import { CodeEditorViewerModule } from './editor-viewer/index.js';
14
15
  import { GithubLinkView } from './github-link/index.js';
16
+ import { ImageViewerModule } from './image-viewer/index.js';
15
17
  import { KernelManagerView } from './kernel-manager/index.js';
16
18
  import { LibroLabApp } from './lab-app.js';
17
19
  import { ContentBottomTabView } from './layout/content-bottom-tab-view.js';
@@ -98,4 +100,6 @@ export const LibroLabModule = ManaModule.create()
98
100
  LibroLabTocModule,
99
101
  LibroPromptCellModule,
100
102
  TerminalModule,
103
+ ImageViewerModule,
104
+ CodeEditorViewerModule,
101
105
  );
@@ -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