1- import { csvParseRows , tsvParseRows } from "d3-dsv" ;
21import { getAttachmentViewer } from "../../../core/registry/index.mts" ;
3- import { PLAYWRIGHT_TRACE_MIME } from "./playwrightTrace.mts" ;
2+ import {
3+ getBuiltinAttachmentType ,
4+ type AttachmentTypeInfo as BuiltinAttachmentTypeInfo ,
5+ } from "./builtinAttachmentType.mts" ;
6+
47type AttachmentViewerDescriptor =
58 import ( "../../../core/registry/types.mts" ) . AttachmentViewerDescriptor ;
6- type IconName = import ( "../../../shared/icon/index.mts" ) . IconName ;
79
8- export type AttachmentTypeInfo = Partial < AttachmentViewerDescriptor > & {
9- type : string | null ;
10- icon : IconName ;
11- parser ?: ( content : string ) => unknown ;
12- } ;
10+ export type AttachmentTypeInfo = BuiltinAttachmentTypeInfo & Partial < AttachmentViewerDescriptor > ;
1311
1412export default function attachmentType ( type : string ) : AttachmentTypeInfo {
1513 const customAttachmentViewer = getAttachmentViewer ( type ) ;
@@ -19,101 +17,6 @@ export default function attachmentType(type: string): AttachmentTypeInfo {
1917 ...customAttachmentViewer ,
2018 } ;
2119 }
22- switch ( type ) {
23- case "image/bmp" :
24- case "image/gif" :
25- case "image/tiff" :
26- case "image/jpeg" :
27- case "image/jpg" :
28- case "image/png" :
29- case "image/webp" :
30- case "image/*" :
31- return {
32- type : "image" ,
33- icon : "lineImagesImage" ,
34- } ;
35- case "text/xml" :
36- case "application/xml" :
37- case "application/json" :
38- case "text/json" :
39- case "text/yaml" :
40- case "application/yaml" :
41- case "application/x-yaml" :
42- case "text/x-yaml" :
43- return {
44- type : "code" ,
45- icon : "lineDevCodeSquare" ,
46- parser : ( d ) => d ,
47- } ;
48- case "text/plain" :
49- case "text/*" :
50- return {
51- type : "text" ,
52- icon : "lineFilesFile2" ,
53- parser : ( d ) => d ,
54- } ;
55- case "application/xhtml+xml" :
56- case "text/html" :
57- return {
58- type : "html" ,
59- icon : "lineDevCodeSquare" ,
60- } ;
61- case "text/csv" :
62- return {
63- type : "table" ,
64- icon : "lineGeneralChecklist3" ,
65- parser : ( d ) => csvParseRows ( d ) ,
66- } ;
67- case "text/tab-separated-values" :
68- return {
69- type : "table" ,
70- icon : "lineGeneralChecklist3" ,
71- parser : ( d ) => tsvParseRows ( d ) ,
72- } ;
73- case "image/svg+xml" :
74- return {
75- type : "svg" ,
76- icon : "lineImagesImage" ,
77- } ;
78- case "video/mp4" :
79- case "video/ogg" :
80- case "video/webm" :
81- return {
82- type : "video" ,
83- icon : "lineHelpersPlayCircle" ,
84- } ;
85- case "text/uri-list" :
86- return {
87- type : "uri" ,
88- icon : "lineGeneralLink1" ,
89- parser : ( d ) =>
90- d
91- . split ( "\n" )
92- . map ( ( line ) => line . trim ( ) )
93- . filter ( ( line ) => line . length > 0 )
94- . map ( ( line ) => ( {
95- comment : line . indexOf ( "#" ) === 0 ,
96- text : line ,
97- } ) ) ,
98- } ;
99- case "application/x-tar" :
100- case "application/x-gtar" :
101- case "application/x-bzip2" :
102- case "application/gzip" :
103- case "application/zip" :
104- return {
105- type : "archive" ,
106- icon : "lineFilesFileAttachment2" ,
107- } ;
108- case PLAYWRIGHT_TRACE_MIME :
109- return {
110- type : "playwright-trace" ,
111- icon : "lineDevCodeSquare" ,
112- } ;
113- default :
114- return {
115- type : null ,
116- icon : "lineFilesFile2" ,
117- } ;
118- }
20+
21+ return getBuiltinAttachmentType ( type ) ;
11922}
0 commit comments