@parca/profile 0.16.237 → 0.16.238

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
+ };
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';