@parca/profile 0.16.237 → 0.16.239

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.
@@ -0,0 +1,33 @@
1
+ // Copyright 2022 The Parca Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+
14
+ import * as hljsLangs from 'react-syntax-highlighter/dist/esm/languages/hljs';
15
+
16
+ import _extLangMap from './ext-to-lang.json';
17
+
18
+ const extLangMap = _extLangMap as Record<string, string[]>;
19
+
20
+ export const langaugeFromFile = (file: string): string => {
21
+ const extension = file.split('.').pop() ?? '';
22
+ if (extLangMap[extension] == null) {
23
+ return 'text';
24
+ }
25
+ const langs: string[] = extLangMap[extension];
26
+ for (const lang of langs) {
27
+ // eslint-disable-next-line import/namespace
28
+ if (hljsLangs[lang] != null) {
29
+ return lang;
30
+ }
31
+ }
32
+ return 'text';
33
+ };
@@ -206,8 +206,8 @@ export const Table = React.memo(function Table({
206
206
  };
207
207
  }, [compareMode]);
208
208
 
209
- if (loading) return <>Loading...</>;
210
- if (data === undefined) return <>Profile has no samples</>;
209
+ if (loading) return <div className="mx-auto text-center">Loading...</div>;
210
+ if (data === undefined) return <div className="mx-auto text-center">Profile has no samples</div>;
211
211
 
212
212
  const table = tableFromIPC(data);
213
213
  const flatColumn = table.getChild('flat');
@@ -215,7 +215,7 @@ export const Table = React.memo(function Table({
215
215
  const cumulativeColumn = table.getChild('cumulative');
216
216
  const cumulativeDiffColumn = table.getChild('cumulative_diff');
217
217
 
218
- if (table.numRows === 0) return <>Profile has no samples</>;
218
+ if (table.numRows === 0) return <div className="mx-auto text-center">Profile has no samples</div>;
219
219
 
220
220
  const rows: row[] = [];
221
221
  // TODO: Figure out how to only read the data of the columns we need for the virtualized table
@@ -222,7 +222,8 @@ export const TopTable = React.memo(function TopTable({
222
222
 
223
223
  const total = top != null ? top.list.length : 0;
224
224
 
225
- if (total === 0 && !loading) return <>Profile has no samples</>;
225
+ if (total === 0 && !loading)
226
+ return <div className="mx-auto text-center">Profile has no samples</div>;
226
227
 
227
228
  return (
228
229
  <div className="relative">
package/typings.d.ts CHANGED
@@ -13,3 +13,4 @@
13
13
 
14
14
  declare module '*.svg';
15
15
  declare module 'react-map-interaction';
16
+ declare module 'react-syntax-highlighter/dist/esm/languages/hljs';