@trebired/frontend 1.8.1 → 1.9.0

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 (172) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/config/normalize.d.ts.map +1 -1
  3. package/dist/config/normalize.js +1 -0
  4. package/dist/config/normalize.js.map +1 -1
  5. package/dist/config/scss.d.ts.map +1 -1
  6. package/dist/config/scss.js +1 -0
  7. package/dist/config/scss.js.map +1 -1
  8. package/dist/config/types.d.ts +1 -1
  9. package/dist/config/types.d.ts.map +1 -1
  10. package/dist/editor/index.d.ts +1 -0
  11. package/dist/editor/index.d.ts.map +1 -1
  12. package/dist/editor/index.js +1 -0
  13. package/dist/editor/index.js.map +1 -1
  14. package/dist/editor/styles/index.scss +10 -0
  15. package/dist/editor/viewer/app.d.ts +21 -0
  16. package/dist/editor/viewer/app.d.ts.map +1 -0
  17. package/dist/editor/viewer/app.js +137 -0
  18. package/dist/editor/viewer/app.js.map +1 -0
  19. package/dist/editor/viewer/fullscreen.d.ts +6 -0
  20. package/dist/editor/viewer/fullscreen.d.ts.map +1 -0
  21. package/dist/editor/viewer/fullscreen.js +30 -0
  22. package/dist/editor/viewer/fullscreen.js.map +1 -0
  23. package/dist/editor/viewer/hooks.d.ts +43 -0
  24. package/dist/editor/viewer/hooks.d.ts.map +1 -0
  25. package/dist/editor/viewer/hooks.js +208 -0
  26. package/dist/editor/viewer/hooks.js.map +1 -0
  27. package/dist/editor/viewer/image.d.ts +3 -0
  28. package/dist/editor/viewer/image.d.ts.map +1 -0
  29. package/dist/editor/viewer/image.js +17 -0
  30. package/dist/editor/viewer/image.js.map +1 -0
  31. package/dist/editor/viewer/index.d.ts +15 -0
  32. package/dist/editor/viewer/index.d.ts.map +1 -0
  33. package/dist/editor/viewer/index.js +39 -0
  34. package/dist/editor/viewer/index.js.map +1 -0
  35. package/dist/editor/viewer/monaco.d.ts +4 -0
  36. package/dist/editor/viewer/monaco.d.ts.map +1 -0
  37. package/dist/editor/viewer/monaco.js +220 -0
  38. package/dist/editor/viewer/monaco.js.map +1 -0
  39. package/dist/editor/viewer/readonly.d.ts +5 -0
  40. package/dist/editor/viewer/readonly.d.ts.map +1 -0
  41. package/dist/editor/viewer/readonly.js +37 -0
  42. package/dist/editor/viewer/readonly.js.map +1 -0
  43. package/dist/editor/viewer/shared.d.ts +13 -0
  44. package/dist/editor/viewer/shared.d.ts.map +1 -0
  45. package/dist/editor/viewer/shared.js +157 -0
  46. package/dist/editor/viewer/shared.js.map +1 -0
  47. package/dist/explorer/components/file/tree/parts.d.ts +19 -0
  48. package/dist/explorer/components/file/tree/parts.d.ts.map +1 -0
  49. package/dist/explorer/components/file/tree/parts.js +29 -0
  50. package/dist/explorer/components/file/tree/parts.js.map +1 -0
  51. package/dist/explorer/components/file/tree/row.d.ts +21 -0
  52. package/dist/explorer/components/file/tree/row.d.ts.map +1 -0
  53. package/dist/explorer/components/file/tree/row.js +78 -0
  54. package/dist/explorer/components/file/tree/row.js.map +1 -0
  55. package/dist/explorer/components/file/tree/shell.d.ts +12 -0
  56. package/dist/explorer/components/file/tree/shell.d.ts.map +1 -0
  57. package/dist/explorer/components/file/tree/shell.js +9 -0
  58. package/dist/explorer/components/file/tree/shell.js.map +1 -0
  59. package/dist/explorer/components/file/tree.d.ts +20 -0
  60. package/dist/explorer/components/file/tree.d.ts.map +1 -0
  61. package/dist/explorer/components/file/tree.js +141 -0
  62. package/dist/explorer/components/file/tree.js.map +1 -0
  63. package/dist/explorer/components/index.d.ts +6 -0
  64. package/dist/explorer/components/index.d.ts.map +1 -0
  65. package/dist/explorer/components/index.js +6 -0
  66. package/dist/explorer/components/index.js.map +1 -0
  67. package/dist/explorer/components/static-file-tree.d.ts +15 -0
  68. package/dist/explorer/components/static-file-tree.d.ts.map +1 -0
  69. package/dist/explorer/components/static-file-tree.js +105 -0
  70. package/dist/explorer/components/static-file-tree.js.map +1 -0
  71. package/dist/explorer/index.d.ts +7 -0
  72. package/dist/explorer/index.d.ts.map +1 -0
  73. package/dist/explorer/index.js +46 -0
  74. package/dist/explorer/index.js.map +1 -0
  75. package/dist/explorer/styles/index.scss +7 -0
  76. package/dist/explorer/tree.d.ts +26 -0
  77. package/dist/explorer/tree.d.ts.map +1 -0
  78. package/dist/explorer/tree.js +130 -0
  79. package/dist/explorer/tree.js.map +1 -0
  80. package/dist/index.d.ts +1 -0
  81. package/dist/index.d.ts.map +1 -1
  82. package/dist/index.js +1 -0
  83. package/dist/index.js.map +1 -1
  84. package/dist/react/index.d.ts +2 -0
  85. package/dist/react/index.d.ts.map +1 -1
  86. package/dist/react/index.js +2 -0
  87. package/dist/react/index.js.map +1 -1
  88. package/dist/src/config/normalize.d.ts.map +1 -1
  89. package/dist/src/config/normalize.js +1 -0
  90. package/dist/src/config/normalize.js.map +1 -1
  91. package/dist/src/config/scss.d.ts.map +1 -1
  92. package/dist/src/config/scss.js +1 -0
  93. package/dist/src/config/scss.js.map +1 -1
  94. package/dist/src/config/types.d.ts +1 -1
  95. package/dist/src/config/types.d.ts.map +1 -1
  96. package/dist/src/editor/index.d.ts +1 -0
  97. package/dist/src/editor/index.d.ts.map +1 -1
  98. package/dist/src/editor/index.js +1 -0
  99. package/dist/src/editor/index.js.map +1 -1
  100. package/dist/src/editor/viewer/app.d.ts +21 -0
  101. package/dist/src/editor/viewer/app.d.ts.map +1 -0
  102. package/dist/src/editor/viewer/app.js +137 -0
  103. package/dist/src/editor/viewer/app.js.map +1 -0
  104. package/dist/src/editor/viewer/fullscreen.d.ts +6 -0
  105. package/dist/src/editor/viewer/fullscreen.d.ts.map +1 -0
  106. package/dist/src/editor/viewer/fullscreen.js +30 -0
  107. package/dist/src/editor/viewer/fullscreen.js.map +1 -0
  108. package/dist/src/editor/viewer/hooks.d.ts +43 -0
  109. package/dist/src/editor/viewer/hooks.d.ts.map +1 -0
  110. package/dist/src/editor/viewer/hooks.js +208 -0
  111. package/dist/src/editor/viewer/hooks.js.map +1 -0
  112. package/dist/src/editor/viewer/image.d.ts +3 -0
  113. package/dist/src/editor/viewer/image.d.ts.map +1 -0
  114. package/dist/src/editor/viewer/image.js +17 -0
  115. package/dist/src/editor/viewer/image.js.map +1 -0
  116. package/dist/src/editor/viewer/index.d.ts +15 -0
  117. package/dist/src/editor/viewer/index.d.ts.map +1 -0
  118. package/dist/src/editor/viewer/index.js +39 -0
  119. package/dist/src/editor/viewer/index.js.map +1 -0
  120. package/dist/src/editor/viewer/monaco.d.ts +4 -0
  121. package/dist/src/editor/viewer/monaco.d.ts.map +1 -0
  122. package/dist/src/editor/viewer/monaco.js +220 -0
  123. package/dist/src/editor/viewer/monaco.js.map +1 -0
  124. package/dist/src/editor/viewer/readonly.d.ts +5 -0
  125. package/dist/src/editor/viewer/readonly.d.ts.map +1 -0
  126. package/dist/src/editor/viewer/readonly.js +37 -0
  127. package/dist/src/editor/viewer/readonly.js.map +1 -0
  128. package/dist/src/editor/viewer/shared.d.ts +13 -0
  129. package/dist/src/editor/viewer/shared.d.ts.map +1 -0
  130. package/dist/src/editor/viewer/shared.js +157 -0
  131. package/dist/src/editor/viewer/shared.js.map +1 -0
  132. package/dist/src/explorer/components/file/tree/parts.d.ts +19 -0
  133. package/dist/src/explorer/components/file/tree/parts.d.ts.map +1 -0
  134. package/dist/src/explorer/components/file/tree/parts.js +29 -0
  135. package/dist/src/explorer/components/file/tree/parts.js.map +1 -0
  136. package/dist/src/explorer/components/file/tree/row.d.ts +21 -0
  137. package/dist/src/explorer/components/file/tree/row.d.ts.map +1 -0
  138. package/dist/src/explorer/components/file/tree/row.js +78 -0
  139. package/dist/src/explorer/components/file/tree/row.js.map +1 -0
  140. package/dist/src/explorer/components/file/tree/shell.d.ts +12 -0
  141. package/dist/src/explorer/components/file/tree/shell.d.ts.map +1 -0
  142. package/dist/src/explorer/components/file/tree/shell.js +9 -0
  143. package/dist/src/explorer/components/file/tree/shell.js.map +1 -0
  144. package/dist/src/explorer/components/file/tree.d.ts +20 -0
  145. package/dist/src/explorer/components/file/tree.d.ts.map +1 -0
  146. package/dist/src/explorer/components/file/tree.js +141 -0
  147. package/dist/src/explorer/components/file/tree.js.map +1 -0
  148. package/dist/src/explorer/components/index.d.ts +6 -0
  149. package/dist/src/explorer/components/index.d.ts.map +1 -0
  150. package/dist/src/explorer/components/index.js +6 -0
  151. package/dist/src/explorer/components/index.js.map +1 -0
  152. package/dist/src/explorer/components/static-file-tree.d.ts +15 -0
  153. package/dist/src/explorer/components/static-file-tree.d.ts.map +1 -0
  154. package/dist/src/explorer/components/static-file-tree.js +105 -0
  155. package/dist/src/explorer/components/static-file-tree.js.map +1 -0
  156. package/dist/src/explorer/index.d.ts +7 -0
  157. package/dist/src/explorer/index.d.ts.map +1 -0
  158. package/dist/src/explorer/index.js +46 -0
  159. package/dist/src/explorer/index.js.map +1 -0
  160. package/dist/src/explorer/tree.d.ts +26 -0
  161. package/dist/src/explorer/tree.d.ts.map +1 -0
  162. package/dist/src/explorer/tree.js +130 -0
  163. package/dist/src/explorer/tree.js.map +1 -0
  164. package/dist/src/index.d.ts +1 -0
  165. package/dist/src/index.d.ts.map +1 -1
  166. package/dist/src/index.js +1 -0
  167. package/dist/src/index.js.map +1 -1
  168. package/dist/src/react/index.d.ts +2 -0
  169. package/dist/src/react/index.d.ts.map +1 -1
  170. package/dist/src/react/index.js +2 -0
  171. package/dist/src/react/index.js.map +1 -1
  172. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  export * from "./components/index.js";
2
2
  export * from "./content.js";
3
+ export * from "./viewer/index.js";
3
4
  import { bindEditorContentFields } from "./content.js";
4
5
  function bindEditors(root = document) {
5
6
  bindEditorContentFields(root);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,SAAS,WAAW,CAAC,OAAiB,QAAQ;IAC5C,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/editor/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,SAAS,WAAW,CAAC,OAAiB,QAAQ;IAC5C,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ declare function EditorViewerApp(props: any): import("react").JSX.Element;
2
+ declare function viewerLabels(input?: any): {
3
+ chooseFileFromTree: any;
4
+ fetchingLatestFileContents: any;
5
+ fileOpenViewMode: any;
6
+ fileTree: any;
7
+ fileTreeDescription: any;
8
+ fileTreeUnavailable: any;
9
+ fileUnavailable: any;
10
+ imageOpenViewMode: any;
11
+ loadingFile: any;
12
+ loadingFileTree: any;
13
+ loadingSelectedFile: any;
14
+ noFileSelected: any;
15
+ noFileTreeAvailable: any;
16
+ pickFileFromTree: any;
17
+ preparingFileBrowserViewMode: any;
18
+ readonlyFileViewer: any;
19
+ };
20
+ export { EditorViewerApp, viewerLabels };
21
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../../src/editor/viewer/app.tsx"],"names":[],"mappings":"AA+BA,iBAAS,eAAe,CAAC,KAAK,EAAE,GAAG,+BAoClC;AAED,iBAAS,YAAY,CAAC,KAAK,GAAE,GAAQ;;;;;;;;;;;;;;;;;EAmBpC;AAqKD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,137 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useMemo, useRef } from "react";
3
+ import { card } from "../../../primitives/components/index.js";
4
+ import { editor_content as EditorContent, editor_sidebar as EditorSidebar } from "../../../editor/components/index.js";
5
+ import { FileTreeView } from "../../../explorer/index.js";
6
+ import { buildFileApiUrl, isImagePath, normalizePath, resolveViewerTreeHeight, text, } from "./shared.js";
7
+ import { useFileState, useFocusedTreeSync, useFullscreenState, useInitialFileCache, useInitialFileState, useInitialTree, useOpenedFile, useSelectedPaths, useTreeState, useUrlPathSync, } from "./hooks.js";
8
+ import { EmptyEditorMessage } from "./readonly.js";
9
+ import { ImagePreviewPane } from "./image.js";
10
+ import { ReadonlyMonacoPane } from "./monaco.js";
11
+ const rootStyle = { flex: "1 1 auto", minHeight: 0 };
12
+ const rowStyle = { alignItems: "stretch", flex: "1 1 auto", minHeight: 0 };
13
+ function EditorViewerApp(props) {
14
+ const rootRef = useRef(null);
15
+ const initialTree = useInitialTree(props);
16
+ const initial = useInitialFileState(props, initialTree);
17
+ const treeState = useTreeState(props, initialTree);
18
+ const pathState = useSelectedPaths(initial);
19
+ const [fileState, setFileState] = useFileState(initial.initialFile);
20
+ const fileCacheRef = useInitialFileCache(initial.initialFile);
21
+ const allowUrlPathSyncRef = useRef(Boolean(initial.requestedPath));
22
+ const fullscreenState = useFullscreenState(rootRef);
23
+ useFocusedTreeSync(treeState, pathState);
24
+ useUrlPathSync(treeState.tree, pathState, allowUrlPathSyncRef);
25
+ useOpenedFile(props, pathState.openedFilePath, fileCacheRef, setFileState);
26
+ const layout = useEditorViewerLayout(props, fileState, fullscreenState);
27
+ return (_jsx("div", { ref: rootRef, className: "column gap-sm grow", style: rootStyle, children: _jsxs("div", { className: "inline-row gap-sm tbf-editor-viewer-layout grow", style: rowStyle, children: [_jsx(ViewerSidebar, { allowUrlPathSyncRef: allowUrlPathSyncRef, focusedPath: pathState.focusedPath, isFullscreen: fullscreenState.isFullscreen, setFocusedPath: pathState.setFocusedPath, setOpenedFilePath: pathState.setOpenedFilePath, treeHeight: layout.treeHeight, treeState: treeState, labels: viewerLabels(props.labels) }), _jsx(ViewerContent, { contentMinHeight: layout.contentMinHeight, fileState: fileState, imagePreviewUrl: layout.imagePreviewUrl, labels: viewerLabels(props.labels) })] }) }));
28
+ }
29
+ function viewerLabels(input = {}) {
30
+ return {
31
+ chooseFileFromTree: input.chooseFileFromTree || "Choose a file from the tree.",
32
+ fetchingLatestFileContents: input.fetchingLatestFileContents || "Fetching latest file contents.",
33
+ fileOpenViewMode: input.fileOpenViewMode || "File open in read-only view mode.",
34
+ fileTree: input.fileTree || "File tree",
35
+ fileTreeDescription: input.fileTreeDescription || "Browse files in this tree.",
36
+ fileTreeUnavailable: input.fileTreeUnavailable || "File tree unavailable",
37
+ fileUnavailable: input.fileUnavailable || "File unavailable",
38
+ imageOpenViewMode: input.imageOpenViewMode || "Image open in preview mode.",
39
+ loadingFile: input.loadingFile || "Loading file",
40
+ loadingFileTree: input.loadingFileTree || "Loading file tree",
41
+ loadingSelectedFile: input.loadingSelectedFile || "Loading selected file.",
42
+ noFileSelected: input.noFileSelected || "No file selected",
43
+ noFileTreeAvailable: input.noFileTreeAvailable || "No file tree available.",
44
+ pickFileFromTree: input.pickFileFromTree || "Pick a file from the tree.",
45
+ preparingFileBrowserViewMode: input.preparingFileBrowserViewMode || "Preparing file browser.",
46
+ readonlyFileViewer: input.readonlyFileViewer || "Readonly file viewer",
47
+ };
48
+ }
49
+ function useEditorViewerLayout(props, fileState, fullscreenState) {
50
+ const imagePreviewUrl = useMemo(() => {
51
+ if (!isImagePath(fileState.path))
52
+ return "";
53
+ return buildFileApiUrl(props.fileBlobApiUrl, fileState.path);
54
+ }, [fileState.path, props.fileBlobApiUrl]);
55
+ return {
56
+ contentMinHeight: fullscreenState.isFullscreen
57
+ ? Math.max(680, fullscreenState.viewportHeight - 220)
58
+ : 560,
59
+ imagePreviewUrl,
60
+ treeHeight: resolveViewerTreeHeight(fullscreenState.isFullscreen, fullscreenState.viewportHeight),
61
+ };
62
+ }
63
+ function ViewerSidebar(props) {
64
+ return (_jsx(EditorSidebar, { className: "column gap-sm no-shrink", description: props.labels.fileTreeDescription, title: props.labels.fileTree, style: {
65
+ flex: props.isFullscreen ? "0 0 360px" : "0 0 320px",
66
+ maxWidth: "100%",
67
+ minHeight: 0,
68
+ minWidth: 280,
69
+ }, children: _jsx(ViewerSidebarBody, { ...props }) }));
70
+ }
71
+ function ViewerSidebarBody(props) {
72
+ if (props.treeState.treeLoading) {
73
+ return (_jsx(EmptyEditorMessage, { copy: props.labels.preparingFileBrowserViewMode, minHeight: 420, title: props.labels.loadingFileTree }));
74
+ }
75
+ if (props.treeState.treeError) {
76
+ return card({
77
+ style: { minHeight: 420 },
78
+ className: "column gap-sm",
79
+ children: (_jsxs(_Fragment, { children: [_jsx("strong", { children: props.labels.fileTreeUnavailable }), _jsx("span", { className: "text-muted text-small text-break", children: props.treeState.treeError })] })),
80
+ });
81
+ }
82
+ return _jsx(ViewerTree, { ...props });
83
+ }
84
+ function ViewerTree(props) {
85
+ return (_jsx(FileTreeView, { autoExpandPaths: props.focusedPath ? [props.focusedPath] : [], emptyMessage: props.labels.noFileTreeAvailable, height: props.treeHeight, highlightedPaths: props.focusedPath ? [props.focusedPath] : [], mode: "browse", scrollbarSize: "md", onFileOpen: (nextPath) => selectViewerPath(props, nextPath, "file"), onPathOpen: (nextPath, meta) => {
86
+ selectViewerPath(props, nextPath, text(meta?.kind).toLowerCase());
87
+ }, tree: props.treeState.tree }));
88
+ }
89
+ function selectViewerPath(props, nextPath, kind) {
90
+ const relPath = normalizePath(nextPath);
91
+ props.allowUrlPathSyncRef.current = true;
92
+ props.setFocusedPath(relPath);
93
+ props.setOpenedFilePath(kind === "dir" ? "" : relPath);
94
+ }
95
+ function ViewerContent(props) {
96
+ return (_jsx(EditorContent, { body: _jsx(ViewerContentBody, { ...props }), className: "column gap-sm grow", description: viewerContentDescription(props.fileState, props.labels), surfaceStyle: { flex: "1 1 auto", minHeight: props.contentMinHeight }, title: props.fileState.path || props.labels.readonlyFileViewer }));
97
+ }
98
+ function ViewerContentBody(props) {
99
+ const { contentMinHeight, fileState, imagePreviewUrl } = props;
100
+ if (fileState.loading) {
101
+ return (_jsx(EmptyEditorMessage, { copy: props.labels.fetchingLatestFileContents, minHeight: contentMinHeight, title: props.labels.loadingFile }));
102
+ }
103
+ if (fileState.error)
104
+ return viewerContentError(props, contentMinHeight);
105
+ if (fileState.path && isImagePath(fileState.path) && imagePreviewUrl) {
106
+ return (_jsx(ImagePreviewPane, { minHeight: contentMinHeight, path: fileState.path, src: imagePreviewUrl }));
107
+ }
108
+ if (fileState.path)
109
+ return readonlyFilePane(fileState, contentMinHeight);
110
+ return emptyViewerContent(props, contentMinHeight);
111
+ }
112
+ function viewerContentError(props, contentMinHeight) {
113
+ return card({
114
+ style: { minHeight: contentMinHeight },
115
+ className: "column gap-sm height-max",
116
+ children: (_jsxs(_Fragment, { children: [_jsx("strong", { children: props.labels.fileUnavailable }), _jsx("span", { className: "text-muted text-small text-break", children: props.fileState.error })] })),
117
+ });
118
+ }
119
+ function readonlyFilePane(fileState, contentMinHeight) {
120
+ return (_jsx(ReadonlyMonacoPane, { content: fileState.content, languageName: fileState.languageName, minHeight: contentMinHeight, path: fileState.path }));
121
+ }
122
+ function emptyViewerContent(props, contentMinHeight) {
123
+ return (_jsxs("div", { className: "column gap-sm center ver-center height-max", style: { minHeight: contentMinHeight }, children: [_jsx("strong", { children: props.labels.noFileSelected }), _jsx("span", { className: "text-muted text-small", children: props.labels.chooseFileFromTree })] }));
124
+ }
125
+ function viewerContentDescription(fileState, labels) {
126
+ if (fileState.loading)
127
+ return labels.loadingSelectedFile;
128
+ if (fileState.error)
129
+ return fileState.error;
130
+ if (!fileState.path)
131
+ return labels.pickFileFromTree;
132
+ if (isImagePath(fileState.path))
133
+ return labels.imageOpenViewMode;
134
+ return labels.fileOpenViewMode;
135
+ }
136
+ export { EditorViewerApp, viewerLabels };
137
+ //# sourceMappingURL=app.js.map
@@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,CAAC,KAAK,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC,gBAAgB,CAAC;IACpD,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,MAAM,CAAC,iBAAiB,CAAC;IACjE,OAAO,MAAM,CAAC,gBAAgB,CAAC;AACjC,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ declare function useFullscreenState(rootRef: any): {
2
+ isFullscreen: boolean;
3
+ viewportHeight: number;
4
+ };
5
+ export { useFullscreenState };
6
+ //# sourceMappingURL=fullscreen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullscreen.d.ts","sourceRoot":"","sources":["../../../../src/editor/viewer/fullscreen.ts"],"names":[],"mappings":"AASA,iBAAS,kBAAkB,CAAC,OAAO,EAAE,GAAG;;;EAqBvC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { useEffect, useState } from "react";
2
+ import { readFullscreenState } from "./shared.js";
3
+ function readViewportHeight() {
4
+ const height = typeof window !== "undefined" ? window.innerHeight : 0;
5
+ return Number.isFinite(height) && height > 0 ? height : 900;
6
+ }
7
+ function useFullscreenState(rootRef) {
8
+ const [isFullscreen, setIsFullscreen] = useState(() => readFullscreenState(rootRef.current));
9
+ const [viewportHeight, setViewportHeight] = useState(() => readViewportHeight());
10
+ useEffect(() => {
11
+ function syncFullscreenState() {
12
+ const nextIsFullscreen = readFullscreenState(rootRef.current);
13
+ const nextViewportHeight = readViewportHeight();
14
+ setIsFullscreen((current) => current === nextIsFullscreen ? current : nextIsFullscreen);
15
+ setViewportHeight((current) => current === nextViewportHeight ? current : nextViewportHeight);
16
+ }
17
+ syncFullscreenState();
18
+ document.addEventListener("tbf:fullscreen-open", syncFullscreenState);
19
+ document.addEventListener("tbf:fullscreen-close", syncFullscreenState);
20
+ window.addEventListener("resize", syncFullscreenState);
21
+ return () => {
22
+ document.removeEventListener("tbf:fullscreen-open", syncFullscreenState);
23
+ document.removeEventListener("tbf:fullscreen-close", syncFullscreenState);
24
+ window.removeEventListener("resize", syncFullscreenState);
25
+ };
26
+ }, []);
27
+ return { isFullscreen, viewportHeight };
28
+ }
29
+ export { useFullscreenState };
30
+ //# sourceMappingURL=fullscreen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fullscreen.js","sourceRoot":"","sources":["../../../../src/editor/viewer/fullscreen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,SAAS,kBAAkB;IACzB,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAY;IACtC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7F,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACjF,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,mBAAmB;YAC1B,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC9D,MAAM,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;YAChD,eAAe,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;YACxF,iBAAiB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;QAChG,CAAC;QACD,mBAAmB,EAAE,CAAC;QACtB,QAAQ,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,mBAAoC,CAAC,CAAC;QACvF,QAAQ,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,mBAAoC,CAAC,CAAC;QACxF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,mBAAoC,CAAC,CAAC;YAC1F,QAAQ,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,mBAAoC,CAAC,CAAC;YAC3F,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { useFullscreenState } from "./fullscreen.js";
2
+ declare function useInitialTree(props: any): any;
3
+ declare function useInitialFileState(props: any, initialTree: any[]): {
4
+ initialFile: any;
5
+ requestedIsDir: boolean;
6
+ requestedPath: string;
7
+ };
8
+ declare function useTreeState(props: any, initialTree: any[]): {
9
+ setTree: import("react").Dispatch<import("react").SetStateAction<any[]>>;
10
+ tree: any[];
11
+ treeError: string;
12
+ treeLoaded: boolean;
13
+ treeLoading: boolean;
14
+ };
15
+ declare function useSelectedPaths(initial: any): {
16
+ focusedPath: any;
17
+ openedFilePath: any;
18
+ setFocusedPath: import("react").Dispatch<any>;
19
+ setOpenedFilePath: import("react").Dispatch<any>;
20
+ };
21
+ declare function useFileState(initialFile: any): [{
22
+ content: string;
23
+ error: string;
24
+ languageName: string;
25
+ loading: boolean;
26
+ path: string;
27
+ }, import("react").Dispatch<import("react").SetStateAction<{
28
+ content: string;
29
+ error: string;
30
+ languageName: string;
31
+ loading: boolean;
32
+ path: string;
33
+ }>>];
34
+ declare function useInitialFileCache(initialFile: any): import("react").RefObject<Map<string, {
35
+ content: string;
36
+ languageName: string;
37
+ path: string;
38
+ }>>;
39
+ declare function useFocusedTreeSync(treeState: any, pathState: any): void;
40
+ declare function useUrlPathSync(tree: any[], pathState: any, allowUrlPathSyncRef: any): void;
41
+ declare function useOpenedFile(props: any, openedFilePath: string, fileCacheRef: any, setFileState: any): void;
42
+ export { useFileState, useFocusedTreeSync, useFullscreenState, useInitialFileCache, useInitialFileState, useInitialTree, useOpenedFile, useSelectedPaths, useTreeState, useUrlPathSync, };
43
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../src/editor/viewer/hooks.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,iBAAS,cAAc,CAAC,KAAK,EAAE,GAAG,OAEjC;AAED,iBAAS,mBAAmB,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE;;;;EAM1D;AAED,iBAAS,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE;;;;;;EAYnD;AA+CD,iBAAS,gBAAgB,CAAC,OAAO,EAAE,GAAG;;;;;EAUrC;AAED,iBAAS,YAAY,CAAC,WAAW,EAAE,GAAG;;;;;;;;;;;;KAWrC;AAED,iBAAS,mBAAmB,CAAC,WAAW,EAAE,GAAG;aACQ,MAAM;kBAAgB,MAAM;UAAQ,MAAM;IAW9F;AAED,iBAAS,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,QAazD;AAED,iBAAS,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,QAoB5E;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,QAc9F;AA0DD,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,GACf,CAAC"}
@@ -0,0 +1,208 @@
1
+ import { useEffect, useMemo, useRef, useState } from "react";
2
+ import { buildFileApiUrl, findTreeNodeByPath, normalizePath, readViewerPathFromUrl, syncViewerPathInUrl, text, } from "./shared.js";
3
+ import { useFullscreenState } from "./fullscreen.js";
4
+ function useInitialTree(props) {
5
+ return useMemo(() => Array.isArray(props.tree) ? props.tree : [], [props.tree]);
6
+ }
7
+ function useInitialFileState(props, initialTree) {
8
+ const initialFile = props.initialFile && typeof props.initialFile === "object" ? props.initialFile : null;
9
+ const requestedPath = normalizePath(props.requestedPath);
10
+ const requestedNode = findTreeNodeByPath(initialTree, requestedPath);
11
+ const requestedIsDir = text(requestedNode?.kind).toLowerCase() === "dir";
12
+ return { initialFile, requestedIsDir, requestedPath };
13
+ }
14
+ function useTreeState(props, initialTree) {
15
+ const [treeLoaded, setTreeLoaded] = useState(props.treeLoaded === true || initialTree.length > 0 || !text(props.treeApiUrl));
16
+ const [tree, setTree] = useState(initialTree);
17
+ const [treeLoading, setTreeLoading] = useState(!treeLoaded && Boolean(text(props.treeApiUrl)));
18
+ const [treeError, setTreeError] = useState("");
19
+ useEffect(() => {
20
+ if (treeLoaded || !text(props.treeApiUrl))
21
+ return undefined;
22
+ return fetchTree(props.treeApiUrl, setTree, setTreeLoaded, setTreeLoading, setTreeError);
23
+ }, [props.treeApiUrl, treeLoaded]);
24
+ return { setTree, tree, treeError, treeLoaded, treeLoading };
25
+ }
26
+ function fetchTree(treeApiUrl, setTree, setTreeLoaded, setTreeLoading, setTreeError) {
27
+ let active = true;
28
+ const loadFailed = "File tree failed to load.";
29
+ setTreeLoading(true);
30
+ setTreeError("");
31
+ fetch(String(treeApiUrl), {
32
+ cache: "no-store",
33
+ credentials: "same-origin",
34
+ headers: { "x-requested-with": "editor-viewer" },
35
+ })
36
+ .then(readJsonOrThrow(loadFailed))
37
+ .then((payload) => {
38
+ if (!active)
39
+ return;
40
+ setTreeLoaded(true);
41
+ setTree(Array.isArray(payload?.data?.tree) ? payload.data.tree : []);
42
+ })
43
+ .catch((error) => {
44
+ if (!active)
45
+ return;
46
+ setTreeLoaded(true);
47
+ setTreeError(text(error?.message, loadFailed));
48
+ })
49
+ .finally(() => {
50
+ if (active)
51
+ setTreeLoading(false);
52
+ });
53
+ return () => {
54
+ active = false;
55
+ };
56
+ }
57
+ function readJsonOrThrow(defaultMessage) {
58
+ return async function readJsonResponse(response) {
59
+ const payload = await response.json().catch(() => null);
60
+ if (!response.ok) {
61
+ throw new Error(text(payload?.message || payload?.error, defaultMessage));
62
+ }
63
+ return payload;
64
+ };
65
+ }
66
+ function useSelectedPaths(initial) {
67
+ const [focusedPath, setFocusedPath] = useState(initial.requestedPath || normalizePath(initial.initialFile?.path));
68
+ const [openedFilePath, setOpenedFilePath] = useState(initial.requestedIsDir
69
+ ? ""
70
+ : normalizePath(initial.initialFile?.path) || initial.requestedPath);
71
+ return { focusedPath, openedFilePath, setFocusedPath, setOpenedFilePath };
72
+ }
73
+ function useFileState(initialFile) {
74
+ return useState(() => {
75
+ const initialPath = normalizePath(initialFile?.path);
76
+ return {
77
+ content: initialFile && initialPath ? String(initialFile.content || "") : "",
78
+ error: "",
79
+ languageName: text(initialFile?.language_name),
80
+ loading: false,
81
+ path: initialPath,
82
+ };
83
+ });
84
+ }
85
+ function useInitialFileCache(initialFile) {
86
+ const fileCacheRef = useRef(new Map());
87
+ useEffect(() => {
88
+ const initialPath = normalizePath(initialFile?.path);
89
+ if (!initialFile || !initialPath)
90
+ return;
91
+ fileCacheRef.current.set(initialPath, {
92
+ content: String(initialFile.content || ""),
93
+ languageName: text(initialFile?.language_name),
94
+ path: initialPath,
95
+ });
96
+ }, [initialFile]);
97
+ return fileCacheRef;
98
+ }
99
+ function useFocusedTreeSync(treeState, pathState) {
100
+ useEffect(() => {
101
+ if (!treeState.tree.length || !pathState.focusedPath)
102
+ return;
103
+ const targetNode = findTreeNodeByPath(treeState.tree, pathState.focusedPath);
104
+ const targetKind = text(targetNode?.kind).toLowerCase();
105
+ if (targetKind === "dir") {
106
+ if (pathState.openedFilePath)
107
+ pathState.setOpenedFilePath("");
108
+ return;
109
+ }
110
+ if (!pathState.openedFilePath && targetNode) {
111
+ pathState.setOpenedFilePath(pathState.focusedPath);
112
+ }
113
+ }, [pathState.focusedPath, pathState.openedFilePath, treeState.tree]);
114
+ }
115
+ function useUrlPathSync(tree, pathState, allowUrlPathSyncRef) {
116
+ useEffect(() => {
117
+ if (allowUrlPathSyncRef.current)
118
+ syncViewerPathInUrl(pathState.focusedPath);
119
+ }, [pathState.focusedPath]);
120
+ useEffect(() => {
121
+ function restorePathFromUrl() {
122
+ const nextPath = readViewerPathFromUrl();
123
+ if (!nextPath) {
124
+ pathState.setFocusedPath("");
125
+ pathState.setOpenedFilePath("");
126
+ return;
127
+ }
128
+ const nextNode = findTreeNodeByPath(tree, nextPath);
129
+ const nextKind = text(nextNode?.kind).toLowerCase();
130
+ pathState.setFocusedPath(nextPath);
131
+ pathState.setOpenedFilePath(nextKind === "dir" ? "" : nextPath);
132
+ }
133
+ window.addEventListener("popstate", restorePathFromUrl);
134
+ return () => window.removeEventListener("popstate", restorePathFromUrl);
135
+ }, [tree]);
136
+ }
137
+ function useOpenedFile(props, openedFilePath, fileCacheRef, setFileState) {
138
+ useEffect(() => {
139
+ const relPath = normalizePath(openedFilePath);
140
+ if (!relPath) {
141
+ setFileState({ content: "", error: "", languageName: "", loading: false, path: "" });
142
+ return undefined;
143
+ }
144
+ const cached = fileCacheRef.current.get(relPath);
145
+ if (cached) {
146
+ setFileState({ ...cached, error: "", loading: false });
147
+ return undefined;
148
+ }
149
+ return fetchFile(props.fileApiUrl, relPath, fileCacheRef, setFileState);
150
+ }, [openedFilePath, props.fileApiUrl]);
151
+ }
152
+ function fetchFile(fileApiUrlInput, relPath, fileCacheRef, setFileState) {
153
+ const fileApiUrl = buildFileApiUrl(fileApiUrlInput, relPath);
154
+ if (!fileApiUrl) {
155
+ setFileState({
156
+ content: "",
157
+ error: "File API is unavailable.",
158
+ languageName: "",
159
+ loading: false,
160
+ path: relPath,
161
+ });
162
+ return undefined;
163
+ }
164
+ let active = true;
165
+ const loadFailed = "File failed to load.";
166
+ setFileState({ content: "", error: "", languageName: "", loading: true, path: relPath });
167
+ fetch(fileApiUrl, {
168
+ credentials: "same-origin",
169
+ headers: { "x-requested-with": "editor-viewer" },
170
+ })
171
+ .then(readJsonOrThrow(loadFailed))
172
+ .then((payload) => {
173
+ if (active)
174
+ applyLoadedFile(payload, relPath, fileCacheRef, setFileState);
175
+ })
176
+ .catch((error) => {
177
+ if (active) {
178
+ setFileState({
179
+ content: "",
180
+ error: text(error?.message, loadFailed),
181
+ languageName: "",
182
+ loading: false,
183
+ path: relPath,
184
+ });
185
+ }
186
+ });
187
+ return () => {
188
+ active = false;
189
+ };
190
+ }
191
+ function applyLoadedFile(payload, relPath, fileCacheRef, setFileState) {
192
+ const data = payload?.data && typeof payload.data === "object" ? payload.data : {};
193
+ const nextState = {
194
+ content: String(data.content || ""),
195
+ error: "",
196
+ languageName: text(data.language_name),
197
+ loading: false,
198
+ path: relPath,
199
+ };
200
+ fileCacheRef.current.set(relPath, {
201
+ content: nextState.content,
202
+ languageName: nextState.languageName,
203
+ path: relPath,
204
+ });
205
+ setFileState(nextState);
206
+ }
207
+ export { useFileState, useFocusedTreeSync, useFullscreenState, useInitialFileCache, useInitialFileState, useInitialTree, useOpenedFile, useSelectedPaths, useTreeState, useUrlPathSync, };
208
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../src/editor/viewer/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,IAAI,GACL,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,SAAS,cAAc,CAAC,KAAU;IAChC,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAU,EAAE,WAAkB;IACzD,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1G,MAAM,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,kBAAkB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;IACzE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,KAAU,EAAE,WA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reviewPane(props: any): import("react").JSX.Element;
2
+ export { ImagePreviewPane };
3
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/editor/viewer/image.tsx"],"names":[],"mappings":"AAEA,iBAAS,gBAAgB,CAAC,KAAK,EAAE,GAAG,+BAuBnC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { text } from "./shared.js";
3
+ function ImagePreviewPane(props) {
4
+ return (_jsx("div", { className: "column gap-sm center ver-center bg-canvas", style: {
5
+ height: "100%",
6
+ minHeight: Number.isFinite(props.minHeight) ? Number(props.minHeight) : 560,
7
+ padding: 16,
8
+ }, children: _jsx("img", { alt: text(props.path, "Image preview"), src: String(props.src || ""), style: {
9
+ display: "block",
10
+ height: "auto",
11
+ maxHeight: "72vh",
12
+ maxWidth: "100%",
13
+ objectFit: "contain",
14
+ } }) }));
15
+ }
16
+ export { ImagePreviewPane };
17
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../../../src/editor/viewer/image.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,SAAS,gBAAgB,CAAC,KAAU;IAClC,OAAO,CACL,cACE,SAAS,EAAC,2CAA2C,EACrD,KAAK,EAAE;YACL,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG;YAC3E,OAAO,EAAE,EAAE;SACZ,YAED,cACE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,EACtC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,EAC5B,KAAK,EAAE;gBACL,OAAO,EAAE,OAAO;gBAChB,MAAM,EAAE,MAAM;gBACd,SAAS,EAAE,MAAM;gBACjB,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,SAAS;aACrB,GACD,GACE,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { ReadonlyMonacoDiffPane } from "./monaco.js";
2
+ import { ReadonlyEditorContentApp, ReadonlyEditorDiffApp } from "./readonly.js";
3
+ declare function mountEditorViewer(container: HTMLElement | null, input: any): void;
4
+ declare function mountReadonlyEditorContent(container: HTMLElement | null, input: any): void;
5
+ declare function mountReadonlyEditorDiff(container: HTMLElement | null, input: any): void;
6
+ declare function unmountEditorViewer(container: HTMLElement | null): void;
7
+ export * from "./app.js";
8
+ export * from "./fullscreen.js";
9
+ export * from "./hooks.js";
10
+ export * from "./image.js";
11
+ export * from "./monaco.js";
12
+ export * from "./readonly.js";
13
+ export * from "./shared.js";
14
+ export { ReadonlyEditorContentApp, ReadonlyEditorDiffApp, ReadonlyMonacoDiffPane, mountEditorViewer, mountReadonlyEditorContent, mountReadonlyEditorDiff, unmountEditorViewer, };
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/editor/viewer/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAGvB,iBAAS,iBAAiB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,QAInE;AAED,iBAAS,0BAA0B,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,QAM5E;AAED,iBAAS,uBAAuB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,QAIzE;AAED,iBAAS,mBAAmB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,QAKzD;AAED,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,mBAAmB,GACpB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { EditorViewerApp } from "./app.js";
3
+ import { ReadonlyMonacoDiffPane } from "./monaco.js";
4
+ import { ReadonlyEditorContentApp, ReadonlyEditorDiffApp, } from "./readonly.js";
5
+ import { deleteRoot, getEditorViewerRoot } from "./shared.js";
6
+ function mountEditorViewer(container, input) {
7
+ const root = getEditorViewerRoot(container);
8
+ if (!root)
9
+ return;
10
+ root.render(_jsx(EditorViewerApp, { ...(input && typeof input === "object" ? input : {}) }));
11
+ }
12
+ function mountReadonlyEditorContent(container, input) {
13
+ const root = getEditorViewerRoot(container);
14
+ if (!root)
15
+ return;
16
+ root.render(_jsx(ReadonlyEditorContentApp, { ...(input && typeof input === "object" ? input : {}) }));
17
+ }
18
+ function mountReadonlyEditorDiff(container, input) {
19
+ const root = getEditorViewerRoot(container);
20
+ if (!root)
21
+ return;
22
+ root.render(_jsx(ReadonlyEditorDiffApp, { ...(input && typeof input === "object" ? input : {}) }));
23
+ }
24
+ function unmountEditorViewer(container) {
25
+ const root = getEditorViewerRoot(container);
26
+ if (!root)
27
+ return;
28
+ root.unmount();
29
+ deleteRoot(container);
30
+ }
31
+ export * from "./app.js";
32
+ export * from "./fullscreen.js";
33
+ export * from "./hooks.js";
34
+ export * from "./image.js";
35
+ export * from "./monaco.js";
36
+ export * from "./readonly.js";
37
+ export * from "./shared.js";
38
+ export { ReadonlyEditorContentApp, ReadonlyEditorDiffApp, ReadonlyMonacoDiffPane, mountEditorViewer, mountReadonlyEditorContent, mountReadonlyEditorDiff, unmountEditorViewer, };
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/editor/viewer/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE9D,SAAS,iBAAiB,CAAC,SAA6B,EAAE,KAAU;IAClE,MAAM,IAAI,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,CAAC,MAAM,CAAC,KAAC,eAAe,OAAK,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,0BAA0B,CAAC,SAA6B,EAAE,KAAU;IAC3E,MAAM,IAAI,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,CAAC,MAAM,CACT,KAAC,wBAAwB,OAAK,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CACpF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,SAA6B,EAAE,KAAU;IACxE,MAAM,IAAI,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,CAAC,MAAM,CAAC,KAAC,qBAAqB,OAAK,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAI,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,mBAAmB,CAAC,SAA6B;IACxD,MAAM,IAAI,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,CAAC,OAAO,EAAE,CAAC;IACf,UAAU,CAAC,SAAS,CAAC,CAAC;AACxB,CAAC;AAED,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,mBAAmB,GACpB,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare function ReadonlyMonacoPane(props: any): import("react").JSX.Element;
2
+ declare function ReadonlyMonacoDiffPane(props: any): import("react").JSX.Element;
3
+ export { ReadonlyMonacoDiffPane, ReadonlyMonacoPane };
4
+ //# sourceMappingURL=monaco.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monaco.d.ts","sourceRoot":"","sources":["../../../../src/editor/viewer/monaco.tsx"],"names":[],"mappings":"AAsLA,iBAAS,kBAAkB,CAAC,KAAK,EAAE,GAAG,+BA6BrC;AAED,iBAAS,sBAAsB,CAAC,KAAK,EAAE,GAAG,+BA+BzC;AAeD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,CAAC"}