@teambit/code.ui.code-tab-page 0.0.0-0a5b3ead38a0a82fc1b225c3a112b013e7fc4be5
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/code-tab-page.module.scss +45 -0
- package/code-tab-page.tsx +251 -0
- package/dist/code-tab-page.d.ts +23 -0
- package/dist/code-tab-page.js +201 -0
- package/dist/code-tab-page.js.map +1 -0
- package/dist/code-tab-page.module.scss +45 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1753881650385.js +7 -0
- package/index.ts +2 -0
- package/package.json +72 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
@import '@teambit/ui-foundation.ui.constants.z-indexes/z-indexes.module.scss';
|
2
|
+
$panelBg: #fafafa;
|
3
|
+
|
4
|
+
.codePage {
|
5
|
+
height: calc(100vh - 56px);
|
6
|
+
width: 100%;
|
7
|
+
}
|
8
|
+
|
9
|
+
.left {
|
10
|
+
min-width: 200px;
|
11
|
+
|
12
|
+
//cannot assign max-width directly to right side
|
13
|
+
max-width: calc(100% - 200px);
|
14
|
+
|
15
|
+
display: flex;
|
16
|
+
}
|
17
|
+
|
18
|
+
.right {
|
19
|
+
position: relative;
|
20
|
+
// background: $panelBg;
|
21
|
+
overflow-y: auto;
|
22
|
+
// this is to fix the right panel when it gets too big or too small
|
23
|
+
min-width: 200px;
|
24
|
+
max-width: calc(100% - 200px);
|
25
|
+
}
|
26
|
+
|
27
|
+
.splitter {
|
28
|
+
position: relative;
|
29
|
+
|
30
|
+
> :first-child {
|
31
|
+
z-index: $pane-splitter-zIndex;
|
32
|
+
position: absolute;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
.collapser {
|
37
|
+
right: 1px;
|
38
|
+
}
|
39
|
+
|
40
|
+
.depNode {
|
41
|
+
overflow: hidden;
|
42
|
+
text-overflow: ellipsis;
|
43
|
+
white-space: nowrap;
|
44
|
+
padding: 0 8px;
|
45
|
+
}
|
@@ -0,0 +1,251 @@
|
|
1
|
+
import { ComponentContext, ComponentID } from '@teambit/component';
|
2
|
+
import classNames from 'classnames';
|
3
|
+
import type { HTMLAttributes } from 'react';
|
4
|
+
import React, { useContext, useState, useMemo } from 'react';
|
5
|
+
import { useSearchParams } from 'react-router-dom';
|
6
|
+
import { flatten } from 'lodash';
|
7
|
+
import { Label } from '@teambit/documenter.ui.label';
|
8
|
+
import { SplitPane, Pane, Layout } from '@teambit/base-ui.surfaces.split-pane.split-pane';
|
9
|
+
import { HoverSplitter } from '@teambit/base-ui.surfaces.split-pane.hover-splitter';
|
10
|
+
import { Collapser } from '@teambit/ui-foundation.ui.buttons.collapser';
|
11
|
+
import { useCode } from '@teambit/code.ui.queries.get-component-code';
|
12
|
+
import type { FileIconSlot } from '@teambit/code';
|
13
|
+
import { CodeView } from '@teambit/code.ui.code-view';
|
14
|
+
import { CodeTabTree } from '@teambit/code.ui.code-tab-tree';
|
15
|
+
import { useIsMobile } from '@teambit/ui-foundation.ui.hooks.use-is-mobile';
|
16
|
+
import type { WidgetProps } from '@teambit/ui-foundation.ui.tree.tree-node';
|
17
|
+
import type { FileIconMatch } from '@teambit/code.ui.utils.get-file-icon';
|
18
|
+
import { getFileIcon } from '@teambit/code.ui.utils.get-file-icon';
|
19
|
+
import { useCodeParams } from '@teambit/code.ui.hooks.use-code-params';
|
20
|
+
import path from 'path-browserify';
|
21
|
+
import type { TreeNode } from '@teambit/design.ui.tree';
|
22
|
+
import {
|
23
|
+
useComponentArtifactFileContent,
|
24
|
+
useComponentArtifacts,
|
25
|
+
} from '@teambit/component.ui.artifacts.queries.use-component-artifacts';
|
26
|
+
import type { ArtifactFile } from '@teambit/component.ui.artifacts.models.component-artifacts-model';
|
27
|
+
import { getArtifactFileDetailsFromUrl } from '@teambit/component.ui.artifacts.models.component-artifacts-model';
|
28
|
+
import isBinaryPath from 'is-binary-path';
|
29
|
+
import { FILE_SIZE_THRESHOLD } from '@teambit/component.ui.artifacts.artifacts-tree';
|
30
|
+
import { useViewedLaneFromUrl } from '@teambit/lanes.hooks.use-viewed-lane-from-url';
|
31
|
+
|
32
|
+
import styles from './code-tab-page.module.scss';
|
33
|
+
|
34
|
+
export type CodePageProps = {
|
35
|
+
fileIconSlot?: FileIconSlot;
|
36
|
+
host: string;
|
37
|
+
codeViewClassName?: string;
|
38
|
+
} & HTMLAttributes<HTMLDivElement>;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Resolves a requested file path against a file tree, handling extension mappings,
|
42
|
+
* parent directory traversal, and index files.
|
43
|
+
*
|
44
|
+
* @param requestedPath The path to resolve (can include ./, ../, etc)
|
45
|
+
* @param fileTree Array of available files
|
46
|
+
* @param mainFile Default file to return if no match is found
|
47
|
+
* @param loadingCode Whether code is currently loading
|
48
|
+
* @returns Resolved file path or undefined if loading
|
49
|
+
*/
|
50
|
+
export function resolveFilePath(
|
51
|
+
requestedPath: string | undefined,
|
52
|
+
fileTree: string[],
|
53
|
+
mainFile: string,
|
54
|
+
loadingCode: boolean
|
55
|
+
): string | undefined {
|
56
|
+
if (loadingCode) return undefined;
|
57
|
+
if (!requestedPath) return mainFile;
|
58
|
+
|
59
|
+
const normalized = path.resolve(requestedPath);
|
60
|
+
|
61
|
+
if (fileTree.includes(normalized)) return normalized;
|
62
|
+
|
63
|
+
const extension = path.extname(normalized);
|
64
|
+
const requestedExt = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'].includes(extension) ? extension : '';
|
65
|
+
const basePathWithoutExt = requestedExt ? normalized.slice(0, -requestedExt.length) : normalized;
|
66
|
+
|
67
|
+
const getTypeScriptVariants = (ext: string): string[] => {
|
68
|
+
switch (ext) {
|
69
|
+
case '.js':
|
70
|
+
return ['.ts', '.tsx'];
|
71
|
+
case '.jsx':
|
72
|
+
return ['.tsx'];
|
73
|
+
case '.mjs':
|
74
|
+
return ['.mts'];
|
75
|
+
case '.cjs':
|
76
|
+
return ['.cts'];
|
77
|
+
default:
|
78
|
+
return [];
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
const possibleExtensions = requestedExt
|
83
|
+
? [requestedExt, ...getTypeScriptVariants(requestedExt)]
|
84
|
+
: ['.ts', '.tsx', '.js'];
|
85
|
+
|
86
|
+
const possiblePaths = [
|
87
|
+
normalized,
|
88
|
+
...possibleExtensions.map((ext) => `${basePathWithoutExt}${ext}`),
|
89
|
+
...possibleExtensions.map((ext) => path.join(normalized, `index${ext}`)),
|
90
|
+
...possibleExtensions.map((ext) => path.join(basePathWithoutExt, `index${ext}`)),
|
91
|
+
].map((p) => path.resolve(p));
|
92
|
+
|
93
|
+
const matchingFiles = fileTree.filter((file) => possiblePaths.includes(path.resolve(file)));
|
94
|
+
|
95
|
+
if (matchingFiles.length > 0) {
|
96
|
+
if (matchingFiles.includes(normalized)) {
|
97
|
+
return normalized;
|
98
|
+
}
|
99
|
+
|
100
|
+
const ordered = matchingFiles.sort((a, b) => {
|
101
|
+
const extA = path.extname(a);
|
102
|
+
const extB = path.extname(b);
|
103
|
+
|
104
|
+
if (extA === requestedExt && extB !== requestedExt) return -1;
|
105
|
+
if (extB === requestedExt && extA !== requestedExt) return 1;
|
106
|
+
|
107
|
+
const isTypeScriptA = ['.ts', '.tsx'].includes(extA);
|
108
|
+
const isTypeScriptB = ['.ts', '.tsx'].includes(extB);
|
109
|
+
if (isTypeScriptA && !isTypeScriptB) return -1;
|
110
|
+
if (isTypeScriptB && !isTypeScriptA) return 1;
|
111
|
+
|
112
|
+
if (extA === '.ts' && extB === '.tsx') return -1;
|
113
|
+
if (extA === '.tsx' && extB === '.ts') return 1;
|
114
|
+
|
115
|
+
return a.length - b.length;
|
116
|
+
});
|
117
|
+
|
118
|
+
return ordered[0];
|
119
|
+
}
|
120
|
+
|
121
|
+
return mainFile;
|
122
|
+
}
|
123
|
+
|
124
|
+
export function CodePage({ className, fileIconSlot, host: hostFromProps, codeViewClassName }: CodePageProps) {
|
125
|
+
const urlParams = useCodeParams();
|
126
|
+
const laneFromUrl = useViewedLaneFromUrl();
|
127
|
+
const [searchParams] = useSearchParams();
|
128
|
+
const scopeFromQueryParams = searchParams.get('scope');
|
129
|
+
const component = useContext(ComponentContext);
|
130
|
+
const host = useMemo(
|
131
|
+
() => (urlParams.version ? 'teambit.scope/scope' : hostFromProps),
|
132
|
+
[urlParams.version, hostFromProps]
|
133
|
+
);
|
134
|
+
|
135
|
+
const { mainFile, fileTree = [], dependencies, devFiles, loading: loadingCode } = useCode(component.id, host);
|
136
|
+
const { data: artifacts = [] } = useComponentArtifacts(host, component.id.toString());
|
137
|
+
|
138
|
+
const currentFile = resolveFilePath(urlParams.file, fileTree, mainFile, loadingCode);
|
139
|
+
|
140
|
+
const currentArtifact = getArtifactFileDetailsFromUrl(artifacts, currentFile);
|
141
|
+
const currentArtifactFile = currentArtifact?.artifactFile;
|
142
|
+
const { data: currentArtifactFileData, loading: loadingArtifact } = useComponentArtifactFileContent(
|
143
|
+
host,
|
144
|
+
{
|
145
|
+
componentId: component.id.toString(),
|
146
|
+
taskId: currentArtifact?.taskId,
|
147
|
+
filePath: currentArtifactFile?.path,
|
148
|
+
},
|
149
|
+
!currentArtifact
|
150
|
+
);
|
151
|
+
|
152
|
+
const currentArtifactFileContent = getArtifactFileContent(
|
153
|
+
(currentArtifactFileData && currentArtifactFileData[0]?.files?.[0]) || undefined
|
154
|
+
);
|
155
|
+
const isMobile = useIsMobile();
|
156
|
+
const [isSidebarOpen, setSidebarOpenness] = useState(!isMobile);
|
157
|
+
const sidebarOpenness = isSidebarOpen ? Layout.row : Layout.left;
|
158
|
+
const fileIconMatchers: FileIconMatch[] = useMemo(() => flatten(fileIconSlot?.values()), [fileIconSlot]);
|
159
|
+
const icon = getFileIcon(fileIconMatchers, currentFile);
|
160
|
+
const loadingArtifactFileContent =
|
161
|
+
loadingArtifact !== undefined ? loadingArtifact : !!currentFile && !currentArtifact;
|
162
|
+
const getHref = React.useCallback(
|
163
|
+
(node) => {
|
164
|
+
const queryParams = new URLSearchParams();
|
165
|
+
|
166
|
+
if (urlParams.version) {
|
167
|
+
queryParams.set('version', urlParams.version);
|
168
|
+
}
|
169
|
+
|
170
|
+
if (scopeFromQueryParams) {
|
171
|
+
queryParams.set('scope', scopeFromQueryParams);
|
172
|
+
}
|
173
|
+
|
174
|
+
return `${node.id}?${queryParams.toString()}`;
|
175
|
+
},
|
176
|
+
[urlParams.version, scopeFromQueryParams]
|
177
|
+
);
|
178
|
+
|
179
|
+
const sortedDeps = useMemo(() => {
|
180
|
+
// need to create a new instance of dependencies because we cant mutate the original array
|
181
|
+
return [...(dependencies ?? [])].sort((a, b) => {
|
182
|
+
return (a.packageName || a.id).localeCompare(b.packageName || b.id);
|
183
|
+
});
|
184
|
+
}, [dependencies?.length]);
|
185
|
+
|
186
|
+
const componentId =
|
187
|
+
laneFromUrl || urlParams.version ? component.id : ComponentID.fromString(component.id.toStringWithoutVersion());
|
188
|
+
|
189
|
+
return (
|
190
|
+
<SplitPane layout={sidebarOpenness} size="85%" className={classNames(styles.codePage, className)}>
|
191
|
+
<Pane className={styles.left}>
|
192
|
+
<CodeView
|
193
|
+
componentId={componentId}
|
194
|
+
currentFile={currentFile}
|
195
|
+
icon={icon}
|
196
|
+
currentFileContent={currentArtifactFileContent}
|
197
|
+
loading={loadingArtifactFileContent || loadingCode}
|
198
|
+
codeSnippetClassName={codeViewClassName}
|
199
|
+
dependencies={dependencies}
|
200
|
+
host={host}
|
201
|
+
/>
|
202
|
+
</Pane>
|
203
|
+
<HoverSplitter className={styles.splitter}>
|
204
|
+
<Collapser
|
205
|
+
placement="left"
|
206
|
+
isOpen={isSidebarOpen}
|
207
|
+
onMouseDown={(e) => e.stopPropagation()} // avoid split-pane drag
|
208
|
+
onClick={() => setSidebarOpenness((x) => !x)}
|
209
|
+
tooltipContent={`${isSidebarOpen ? 'Hide' : 'Show'} file tree`}
|
210
|
+
className={styles.collapser}
|
211
|
+
/>
|
212
|
+
</HoverSplitter>
|
213
|
+
<Pane className={styles.right}>
|
214
|
+
<CodeTabTree
|
215
|
+
host={host}
|
216
|
+
currentFile={currentFile}
|
217
|
+
dependencies={sortedDeps}
|
218
|
+
fileTree={fileTree}
|
219
|
+
widgets={useMemo(() => [generateWidget(mainFile, devFiles)], [mainFile, devFiles])}
|
220
|
+
getHref={getHref}
|
221
|
+
getIcon={useMemo(() => generateIcon(fileIconMatchers), fileIconMatchers)}
|
222
|
+
/>
|
223
|
+
</Pane>
|
224
|
+
</SplitPane>
|
225
|
+
);
|
226
|
+
}
|
227
|
+
|
228
|
+
function generateWidget(mainFile?: string, devFiles?: string[]) {
|
229
|
+
return function Widget({ node }: WidgetProps<any>) {
|
230
|
+
const fileName = node?.id;
|
231
|
+
if (fileName === mainFile) {
|
232
|
+
return <Label className={styles.label}>main</Label>;
|
233
|
+
}
|
234
|
+
if (devFiles?.includes(fileName)) {
|
235
|
+
return <Label className={styles.label}>dev</Label>;
|
236
|
+
}
|
237
|
+
return null;
|
238
|
+
};
|
239
|
+
}
|
240
|
+
|
241
|
+
export function generateIcon(fileIconMatchers: FileIconMatch[]) {
|
242
|
+
return function Icon({ id }: TreeNode) {
|
243
|
+
return getFileIcon(fileIconMatchers, id);
|
244
|
+
};
|
245
|
+
}
|
246
|
+
|
247
|
+
function getArtifactFileContent(file?: ArtifactFile | undefined): string | undefined {
|
248
|
+
if (!file) return undefined;
|
249
|
+
if (isBinaryPath(file.path) || (file.size ?? 0) > FILE_SIZE_THRESHOLD) return undefined;
|
250
|
+
return file.content;
|
251
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
2
|
+
import React from 'react';
|
3
|
+
import type { FileIconSlot } from '@teambit/code';
|
4
|
+
import type { FileIconMatch } from '@teambit/code.ui.utils.get-file-icon';
|
5
|
+
import type { TreeNode } from '@teambit/design.ui.tree';
|
6
|
+
export type CodePageProps = {
|
7
|
+
fileIconSlot?: FileIconSlot;
|
8
|
+
host: string;
|
9
|
+
codeViewClassName?: string;
|
10
|
+
} & HTMLAttributes<HTMLDivElement>;
|
11
|
+
/**
|
12
|
+
* Resolves a requested file path against a file tree, handling extension mappings,
|
13
|
+
* parent directory traversal, and index files.
|
14
|
+
*
|
15
|
+
* @param requestedPath The path to resolve (can include ./, ../, etc)
|
16
|
+
* @param fileTree Array of available files
|
17
|
+
* @param mainFile Default file to return if no match is found
|
18
|
+
* @param loadingCode Whether code is currently loading
|
19
|
+
* @returns Resolved file path or undefined if loading
|
20
|
+
*/
|
21
|
+
export declare function resolveFilePath(requestedPath: string | undefined, fileTree: string[], mainFile: string, loadingCode: boolean): string | undefined;
|
22
|
+
export declare function CodePage({ className, fileIconSlot, host: hostFromProps, codeViewClassName }: CodePageProps): React.JSX.Element;
|
23
|
+
export declare function generateIcon(fileIconMatchers: FileIconMatch[]): ({ id }: TreeNode) => string;
|
@@ -0,0 +1,201 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.resolveFilePath = resolveFilePath;
|
30
|
+
exports.CodePage = CodePage;
|
31
|
+
exports.generateIcon = generateIcon;
|
32
|
+
const component_1 = require("@teambit/component");
|
33
|
+
const classnames_1 = __importDefault(require("classnames"));
|
34
|
+
const react_1 = __importStar(require("react"));
|
35
|
+
const react_router_dom_1 = require("react-router-dom");
|
36
|
+
const lodash_1 = require("lodash");
|
37
|
+
const documenter_ui_label_1 = require("@teambit/documenter.ui.label");
|
38
|
+
const base_ui_surfaces_split_pane_split_pane_1 = require("@teambit/base-ui.surfaces.split-pane.split-pane");
|
39
|
+
const base_ui_surfaces_split_pane_hover_splitter_1 = require("@teambit/base-ui.surfaces.split-pane.hover-splitter");
|
40
|
+
const ui_foundation_ui_buttons_collapser_1 = require("@teambit/ui-foundation.ui.buttons.collapser");
|
41
|
+
const code_ui_queries_get_component_code_1 = require("@teambit/code.ui.queries.get-component-code");
|
42
|
+
const code_ui_code_view_1 = require("@teambit/code.ui.code-view");
|
43
|
+
const code_ui_code_tab_tree_1 = require("@teambit/code.ui.code-tab-tree");
|
44
|
+
const ui_foundation_ui_hooks_use_is_mobile_1 = require("@teambit/ui-foundation.ui.hooks.use-is-mobile");
|
45
|
+
const code_ui_utils_get_file_icon_1 = require("@teambit/code.ui.utils.get-file-icon");
|
46
|
+
const code_ui_hooks_use_code_params_1 = require("@teambit/code.ui.hooks.use-code-params");
|
47
|
+
const path_browserify_1 = __importDefault(require("path-browserify"));
|
48
|
+
const component_ui_artifacts_queries_use_component_artifacts_1 = require("@teambit/component.ui.artifacts.queries.use-component-artifacts");
|
49
|
+
const component_ui_artifacts_models_component_artifacts_model_1 = require("@teambit/component.ui.artifacts.models.component-artifacts-model");
|
50
|
+
const is_binary_path_1 = __importDefault(require("is-binary-path"));
|
51
|
+
const component_ui_artifacts_artifacts_tree_1 = require("@teambit/component.ui.artifacts.artifacts-tree");
|
52
|
+
const lanes_hooks_use_viewed_lane_from_url_1 = require("@teambit/lanes.hooks.use-viewed-lane-from-url");
|
53
|
+
const code_tab_page_module_scss_1 = __importDefault(require("./code-tab-page.module.scss"));
|
54
|
+
/**
|
55
|
+
* Resolves a requested file path against a file tree, handling extension mappings,
|
56
|
+
* parent directory traversal, and index files.
|
57
|
+
*
|
58
|
+
* @param requestedPath The path to resolve (can include ./, ../, etc)
|
59
|
+
* @param fileTree Array of available files
|
60
|
+
* @param mainFile Default file to return if no match is found
|
61
|
+
* @param loadingCode Whether code is currently loading
|
62
|
+
* @returns Resolved file path or undefined if loading
|
63
|
+
*/
|
64
|
+
function resolveFilePath(requestedPath, fileTree, mainFile, loadingCode) {
|
65
|
+
if (loadingCode)
|
66
|
+
return undefined;
|
67
|
+
if (!requestedPath)
|
68
|
+
return mainFile;
|
69
|
+
const normalized = path_browserify_1.default.resolve(requestedPath);
|
70
|
+
if (fileTree.includes(normalized))
|
71
|
+
return normalized;
|
72
|
+
const extension = path_browserify_1.default.extname(normalized);
|
73
|
+
const requestedExt = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'].includes(extension) ? extension : '';
|
74
|
+
const basePathWithoutExt = requestedExt ? normalized.slice(0, -requestedExt.length) : normalized;
|
75
|
+
const getTypeScriptVariants = (ext) => {
|
76
|
+
switch (ext) {
|
77
|
+
case '.js':
|
78
|
+
return ['.ts', '.tsx'];
|
79
|
+
case '.jsx':
|
80
|
+
return ['.tsx'];
|
81
|
+
case '.mjs':
|
82
|
+
return ['.mts'];
|
83
|
+
case '.cjs':
|
84
|
+
return ['.cts'];
|
85
|
+
default:
|
86
|
+
return [];
|
87
|
+
}
|
88
|
+
};
|
89
|
+
const possibleExtensions = requestedExt
|
90
|
+
? [requestedExt, ...getTypeScriptVariants(requestedExt)]
|
91
|
+
: ['.ts', '.tsx', '.js'];
|
92
|
+
const possiblePaths = [
|
93
|
+
normalized,
|
94
|
+
...possibleExtensions.map((ext) => `${basePathWithoutExt}${ext}`),
|
95
|
+
...possibleExtensions.map((ext) => path_browserify_1.default.join(normalized, `index${ext}`)),
|
96
|
+
...possibleExtensions.map((ext) => path_browserify_1.default.join(basePathWithoutExt, `index${ext}`)),
|
97
|
+
].map((p) => path_browserify_1.default.resolve(p));
|
98
|
+
const matchingFiles = fileTree.filter((file) => possiblePaths.includes(path_browserify_1.default.resolve(file)));
|
99
|
+
if (matchingFiles.length > 0) {
|
100
|
+
if (matchingFiles.includes(normalized)) {
|
101
|
+
return normalized;
|
102
|
+
}
|
103
|
+
const ordered = matchingFiles.sort((a, b) => {
|
104
|
+
const extA = path_browserify_1.default.extname(a);
|
105
|
+
const extB = path_browserify_1.default.extname(b);
|
106
|
+
if (extA === requestedExt && extB !== requestedExt)
|
107
|
+
return -1;
|
108
|
+
if (extB === requestedExt && extA !== requestedExt)
|
109
|
+
return 1;
|
110
|
+
const isTypeScriptA = ['.ts', '.tsx'].includes(extA);
|
111
|
+
const isTypeScriptB = ['.ts', '.tsx'].includes(extB);
|
112
|
+
if (isTypeScriptA && !isTypeScriptB)
|
113
|
+
return -1;
|
114
|
+
if (isTypeScriptB && !isTypeScriptA)
|
115
|
+
return 1;
|
116
|
+
if (extA === '.ts' && extB === '.tsx')
|
117
|
+
return -1;
|
118
|
+
if (extA === '.tsx' && extB === '.ts')
|
119
|
+
return 1;
|
120
|
+
return a.length - b.length;
|
121
|
+
});
|
122
|
+
return ordered[0];
|
123
|
+
}
|
124
|
+
return mainFile;
|
125
|
+
}
|
126
|
+
function CodePage({ className, fileIconSlot, host: hostFromProps, codeViewClassName }) {
|
127
|
+
var _a, _b;
|
128
|
+
const urlParams = (0, code_ui_hooks_use_code_params_1.useCodeParams)();
|
129
|
+
const laneFromUrl = (0, lanes_hooks_use_viewed_lane_from_url_1.useViewedLaneFromUrl)();
|
130
|
+
const [searchParams] = (0, react_router_dom_1.useSearchParams)();
|
131
|
+
const scopeFromQueryParams = searchParams.get('scope');
|
132
|
+
const component = (0, react_1.useContext)(component_1.ComponentContext);
|
133
|
+
const host = (0, react_1.useMemo)(() => (urlParams.version ? 'teambit.scope/scope' : hostFromProps), [urlParams.version, hostFromProps]);
|
134
|
+
const { mainFile, fileTree = [], dependencies, devFiles, loading: loadingCode } = (0, code_ui_queries_get_component_code_1.useCode)(component.id, host);
|
135
|
+
const { data: artifacts = [] } = (0, component_ui_artifacts_queries_use_component_artifacts_1.useComponentArtifacts)(host, component.id.toString());
|
136
|
+
const currentFile = resolveFilePath(urlParams.file, fileTree, mainFile, loadingCode);
|
137
|
+
const currentArtifact = (0, component_ui_artifacts_models_component_artifacts_model_1.getArtifactFileDetailsFromUrl)(artifacts, currentFile);
|
138
|
+
const currentArtifactFile = currentArtifact === null || currentArtifact === void 0 ? void 0 : currentArtifact.artifactFile;
|
139
|
+
const { data: currentArtifactFileData, loading: loadingArtifact } = (0, component_ui_artifacts_queries_use_component_artifacts_1.useComponentArtifactFileContent)(host, {
|
140
|
+
componentId: component.id.toString(),
|
141
|
+
taskId: currentArtifact === null || currentArtifact === void 0 ? void 0 : currentArtifact.taskId,
|
142
|
+
filePath: currentArtifactFile === null || currentArtifactFile === void 0 ? void 0 : currentArtifactFile.path,
|
143
|
+
}, !currentArtifact);
|
144
|
+
const currentArtifactFileContent = getArtifactFileContent((currentArtifactFileData && ((_b = (_a = currentArtifactFileData[0]) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0])) || undefined);
|
145
|
+
const isMobile = (0, ui_foundation_ui_hooks_use_is_mobile_1.useIsMobile)();
|
146
|
+
const [isSidebarOpen, setSidebarOpenness] = (0, react_1.useState)(!isMobile);
|
147
|
+
const sidebarOpenness = isSidebarOpen ? base_ui_surfaces_split_pane_split_pane_1.Layout.row : base_ui_surfaces_split_pane_split_pane_1.Layout.left;
|
148
|
+
const fileIconMatchers = (0, react_1.useMemo)(() => (0, lodash_1.flatten)(fileIconSlot === null || fileIconSlot === void 0 ? void 0 : fileIconSlot.values()), [fileIconSlot]);
|
149
|
+
const icon = (0, code_ui_utils_get_file_icon_1.getFileIcon)(fileIconMatchers, currentFile);
|
150
|
+
const loadingArtifactFileContent = loadingArtifact !== undefined ? loadingArtifact : !!currentFile && !currentArtifact;
|
151
|
+
const getHref = react_1.default.useCallback((node) => {
|
152
|
+
const queryParams = new URLSearchParams();
|
153
|
+
if (urlParams.version) {
|
154
|
+
queryParams.set('version', urlParams.version);
|
155
|
+
}
|
156
|
+
if (scopeFromQueryParams) {
|
157
|
+
queryParams.set('scope', scopeFromQueryParams);
|
158
|
+
}
|
159
|
+
return `${node.id}?${queryParams.toString()}`;
|
160
|
+
}, [urlParams.version, scopeFromQueryParams]);
|
161
|
+
const sortedDeps = (0, react_1.useMemo)(() => {
|
162
|
+
// need to create a new instance of dependencies because we cant mutate the original array
|
163
|
+
return [...(dependencies !== null && dependencies !== void 0 ? dependencies : [])].sort((a, b) => {
|
164
|
+
return (a.packageName || a.id).localeCompare(b.packageName || b.id);
|
165
|
+
});
|
166
|
+
}, [dependencies === null || dependencies === void 0 ? void 0 : dependencies.length]);
|
167
|
+
const componentId = laneFromUrl || urlParams.version ? component.id : component_1.ComponentID.fromString(component.id.toStringWithoutVersion());
|
168
|
+
return (react_1.default.createElement(base_ui_surfaces_split_pane_split_pane_1.SplitPane, { layout: sidebarOpenness, size: "85%", className: (0, classnames_1.default)(code_tab_page_module_scss_1.default.codePage, className) },
|
169
|
+
react_1.default.createElement(base_ui_surfaces_split_pane_split_pane_1.Pane, { className: code_tab_page_module_scss_1.default.left },
|
170
|
+
react_1.default.createElement(code_ui_code_view_1.CodeView, { componentId: componentId, currentFile: currentFile, icon: icon, currentFileContent: currentArtifactFileContent, loading: loadingArtifactFileContent || loadingCode, codeSnippetClassName: codeViewClassName, dependencies: dependencies, host: host })),
|
171
|
+
react_1.default.createElement(base_ui_surfaces_split_pane_hover_splitter_1.HoverSplitter, { className: code_tab_page_module_scss_1.default.splitter },
|
172
|
+
react_1.default.createElement(ui_foundation_ui_buttons_collapser_1.Collapser, { placement: "left", isOpen: isSidebarOpen, onMouseDown: (e) => e.stopPropagation(), onClick: () => setSidebarOpenness((x) => !x), tooltipContent: `${isSidebarOpen ? 'Hide' : 'Show'} file tree`, className: code_tab_page_module_scss_1.default.collapser })),
|
173
|
+
react_1.default.createElement(base_ui_surfaces_split_pane_split_pane_1.Pane, { className: code_tab_page_module_scss_1.default.right },
|
174
|
+
react_1.default.createElement(code_ui_code_tab_tree_1.CodeTabTree, { host: host, currentFile: currentFile, dependencies: sortedDeps, fileTree: fileTree, widgets: (0, react_1.useMemo)(() => [generateWidget(mainFile, devFiles)], [mainFile, devFiles]), getHref: getHref, getIcon: (0, react_1.useMemo)(() => generateIcon(fileIconMatchers), fileIconMatchers) }))));
|
175
|
+
}
|
176
|
+
function generateWidget(mainFile, devFiles) {
|
177
|
+
return function Widget({ node }) {
|
178
|
+
const fileName = node === null || node === void 0 ? void 0 : node.id;
|
179
|
+
if (fileName === mainFile) {
|
180
|
+
return react_1.default.createElement(documenter_ui_label_1.Label, { className: code_tab_page_module_scss_1.default.label }, "main");
|
181
|
+
}
|
182
|
+
if (devFiles === null || devFiles === void 0 ? void 0 : devFiles.includes(fileName)) {
|
183
|
+
return react_1.default.createElement(documenter_ui_label_1.Label, { className: code_tab_page_module_scss_1.default.label }, "dev");
|
184
|
+
}
|
185
|
+
return null;
|
186
|
+
};
|
187
|
+
}
|
188
|
+
function generateIcon(fileIconMatchers) {
|
189
|
+
return function Icon({ id }) {
|
190
|
+
return (0, code_ui_utils_get_file_icon_1.getFileIcon)(fileIconMatchers, id);
|
191
|
+
};
|
192
|
+
}
|
193
|
+
function getArtifactFileContent(file) {
|
194
|
+
var _a;
|
195
|
+
if (!file)
|
196
|
+
return undefined;
|
197
|
+
if ((0, is_binary_path_1.default)(file.path) || ((_a = file.size) !== null && _a !== void 0 ? _a : 0) > component_ui_artifacts_artifacts_tree_1.FILE_SIZE_THRESHOLD)
|
198
|
+
return undefined;
|
199
|
+
return file.content;
|
200
|
+
}
|
201
|
+
//# sourceMappingURL=code-tab-page.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"code-tab-page.js","sourceRoot":"","sources":["../code-tab-page.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,0CAwEC;AAED,4BAsGC;AAeD,oCAIC;AApPD,kDAAmE;AACnE,4DAAoC;AAEpC,+CAA6D;AAC7D,uDAAmD;AACnD,mCAAiC;AACjC,sEAAqD;AACrD,4GAA0F;AAC1F,oHAAoF;AACpF,oGAAwE;AACxE,oGAAsE;AAEtE,kEAAsD;AACtD,0EAA6D;AAC7D,wGAA4E;AAG5E,sFAAmE;AACnE,0FAAuE;AACvE,sEAAmC;AAEnC,4IAGyE;AAEzE,8IAAiH;AACjH,oEAA0C;AAC1C,0GAAqF;AACrF,wGAAqF;AAErF,4FAAiD;AAQjD;;;;;;;;;GASG;AACH,SAAgB,eAAe,CAC7B,aAAiC,EACjC,QAAkB,EAClB,QAAgB,EAChB,WAAoB;IAEpB,IAAI,WAAW;QAAE,OAAO,SAAS,CAAC;IAClC,IAAI,CAAC,aAAa;QAAE,OAAO,QAAQ,CAAC;IAEpC,MAAM,UAAU,GAAG,yBAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE/C,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IAErD,MAAM,SAAS,GAAG,yBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAA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+
.codePage {
|
5
|
+
height: calc(100vh - 56px);
|
6
|
+
width: 100%;
|
7
|
+
}
|
8
|
+
|
9
|
+
.left {
|
10
|
+
min-width: 200px;
|
11
|
+
|
12
|
+
//cannot assign max-width directly to right side
|
13
|
+
max-width: calc(100% - 200px);
|
14
|
+
|
15
|
+
display: flex;
|
16
|
+
}
|
17
|
+
|
18
|
+
.right {
|
19
|
+
position: relative;
|
20
|
+
// background: $panelBg;
|
21
|
+
overflow-y: auto;
|
22
|
+
// this is to fix the right panel when it gets too big or too small
|
23
|
+
min-width: 200px;
|
24
|
+
max-width: calc(100% - 200px);
|
25
|
+
}
|
26
|
+
|
27
|
+
.splitter {
|
28
|
+
position: relative;
|
29
|
+
|
30
|
+
> :first-child {
|
31
|
+
z-index: $pane-splitter-zIndex;
|
32
|
+
position: absolute;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
.collapser {
|
37
|
+
right: 1px;
|
38
|
+
}
|
39
|
+
|
40
|
+
.depNode {
|
41
|
+
overflow: hidden;
|
42
|
+
text-overflow: ellipsis;
|
43
|
+
white-space: nowrap;
|
44
|
+
padding: 0 8px;
|
45
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.generateIcon = exports.CodePage = void 0;
|
4
|
+
var code_tab_page_1 = require("./code-tab-page");
|
5
|
+
Object.defineProperty(exports, "CodePage", { enumerable: true, get: function () { return code_tab_page_1.CodePage; } });
|
6
|
+
Object.defineProperty(exports, "generateIcon", { enumerable: true, get: function () { return code_tab_page_1.generateIcon; } });
|
7
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AAAhD,yGAAA,QAAQ,OAAA;AAAE,6GAAA,YAAY,OAAA"}
|
package/index.ts
ADDED
package/package.json
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
{
|
2
|
+
"name": "@teambit/code.ui.code-tab-page",
|
3
|
+
"version": "0.0.0-0a5b3ead38a0a82fc1b225c3a112b013e7fc4be5",
|
4
|
+
"homepage": "https://bit.cloud/teambit/code/ui/code-tab-page",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"componentId": {
|
7
|
+
"scope": "teambit.code",
|
8
|
+
"name": "ui/code-tab-page",
|
9
|
+
"version": "0a5b3ead38a0a82fc1b225c3a112b013e7fc4be5"
|
10
|
+
},
|
11
|
+
"dependencies": {
|
12
|
+
"classnames": "2.2.6",
|
13
|
+
"is-binary-path": "2.1.0",
|
14
|
+
"lodash": "4.17.21",
|
15
|
+
"path-browserify": "^1.0.1",
|
16
|
+
"core-js": "^3.0.0",
|
17
|
+
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.504",
|
18
|
+
"@teambit/base-ui.surfaces.split-pane.hover-splitter": "1.0.0",
|
19
|
+
"@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
|
20
|
+
"@teambit/code.ui.utils.get-file-icon": "0.0.496",
|
21
|
+
"@teambit/component.ui.artifacts.models.component-artifacts-model": "0.0.12",
|
22
|
+
"@teambit/documenter.ui.label": "4.0.3",
|
23
|
+
"@teambit/ui-foundation.ui.hooks.use-is-mobile": "0.0.199",
|
24
|
+
"@teambit/code.ui.code-tab-tree": "0.0.618",
|
25
|
+
"@teambit/code.ui.hooks.use-code-params": "0.0.497",
|
26
|
+
"@teambit/code.ui.queries.get-component-code": "0.0.503",
|
27
|
+
"@teambit/component.ui.artifacts.artifacts-tree": "0.0.28",
|
28
|
+
"@teambit/component.ui.artifacts.queries.use-component-artifacts": "0.0.14",
|
29
|
+
"@teambit/design.ui.tree": "0.0.16",
|
30
|
+
"@teambit/ui-foundation.ui.tree.tree-node": "0.0.517",
|
31
|
+
"@teambit/code.ui.code-view": "0.0.0-c535972a20146918fa970d0fdeeba1d8358f8384",
|
32
|
+
"@teambit/lanes.hooks.use-viewed-lane-from-url": "0.0.0-e66a753bf147ef03aea5ce8b7e69b286fde48737",
|
33
|
+
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.0-3a2857def44d9dbe2a378aa370c6147bc5f8002e"
|
34
|
+
},
|
35
|
+
"devDependencies": {
|
36
|
+
"@types/classnames": "2.2.11",
|
37
|
+
"@types/lodash": "4.14.165",
|
38
|
+
"@types/react": "^17.0.8",
|
39
|
+
"@types/mocha": "9.1.0",
|
40
|
+
"@types/node": "12.20.4",
|
41
|
+
"@types/react-dom": "^17.0.5",
|
42
|
+
"@types/jest": "^26.0.0",
|
43
|
+
"@babel/runtime": "7.20.0",
|
44
|
+
"@types/testing-library__jest-dom": "5.9.5"
|
45
|
+
},
|
46
|
+
"peerDependencies": {
|
47
|
+
"react-router-dom": "^6.22.3",
|
48
|
+
"react": "^16.8.0 || ^17.0.0",
|
49
|
+
"react-dom": "^16.8.0 || ^17.0.0"
|
50
|
+
},
|
51
|
+
"license": "Apache-2.0",
|
52
|
+
"optionalDependencies": {},
|
53
|
+
"peerDependenciesMeta": {},
|
54
|
+
"private": false,
|
55
|
+
"engines": {
|
56
|
+
"node": ">=12.22.0"
|
57
|
+
},
|
58
|
+
"repository": {
|
59
|
+
"type": "git",
|
60
|
+
"url": "https://github.com/teambit/bit"
|
61
|
+
},
|
62
|
+
"keywords": [
|
63
|
+
"bit",
|
64
|
+
"components",
|
65
|
+
"collaboration",
|
66
|
+
"web",
|
67
|
+
"react",
|
68
|
+
"react-components",
|
69
|
+
"angular",
|
70
|
+
"angular-components"
|
71
|
+
]
|
72
|
+
}
|
package/types/asset.d.ts
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
declare module '*.png' {
|
2
|
+
const value: any;
|
3
|
+
export = value;
|
4
|
+
}
|
5
|
+
declare module '*.svg' {
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
7
|
+
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
9
|
+
const src: string;
|
10
|
+
export default src;
|
11
|
+
}
|
12
|
+
|
13
|
+
// @TODO Gilad
|
14
|
+
declare module '*.jpg' {
|
15
|
+
const value: any;
|
16
|
+
export = value;
|
17
|
+
}
|
18
|
+
declare module '*.jpeg' {
|
19
|
+
const value: any;
|
20
|
+
export = value;
|
21
|
+
}
|
22
|
+
declare module '*.gif' {
|
23
|
+
const value: any;
|
24
|
+
export = value;
|
25
|
+
}
|
26
|
+
declare module '*.bmp' {
|
27
|
+
const value: any;
|
28
|
+
export = value;
|
29
|
+
}
|
package/types/style.d.ts
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
declare module '*.module.css' {
|
2
|
+
const classes: { readonly [key: string]: string };
|
3
|
+
export default classes;
|
4
|
+
}
|
5
|
+
declare module '*.module.scss' {
|
6
|
+
const classes: { readonly [key: string]: string };
|
7
|
+
export default classes;
|
8
|
+
}
|
9
|
+
declare module '*.module.sass' {
|
10
|
+
const classes: { readonly [key: string]: string };
|
11
|
+
export default classes;
|
12
|
+
}
|
13
|
+
|
14
|
+
declare module '*.module.less' {
|
15
|
+
const classes: { readonly [key: string]: string };
|
16
|
+
export default classes;
|
17
|
+
}
|
18
|
+
|
19
|
+
declare module '*.less' {
|
20
|
+
const classes: { readonly [key: string]: string };
|
21
|
+
export default classes;
|
22
|
+
}
|
23
|
+
|
24
|
+
declare module '*.css' {
|
25
|
+
const classes: { readonly [key: string]: string };
|
26
|
+
export default classes;
|
27
|
+
}
|
28
|
+
|
29
|
+
declare module '*.sass' {
|
30
|
+
const classes: { readonly [key: string]: string };
|
31
|
+
export default classes;
|
32
|
+
}
|
33
|
+
|
34
|
+
declare module '*.scss' {
|
35
|
+
const classes: { readonly [key: string]: string };
|
36
|
+
export default classes;
|
37
|
+
}
|
38
|
+
|
39
|
+
declare module '*.mdx' {
|
40
|
+
const component: any;
|
41
|
+
export default component;
|
42
|
+
}
|