aboutsummaryrefslogtreecommitdiffhomepage
path: root/media/builtin.go
blob: aafe245c9f80e1671e7a089c5c7afc6db0d1375a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package media

type BuiltinTypes struct {
	CalendarType   Type
	CSSType        Type
	SCSSType       Type
	SASSType       Type
	CSVType        Type
	HTMLType       Type
	JavascriptType Type
	TypeScriptType Type
	TSXType        Type
	JSXType        Type

	JSONType           Type
	WebAppManifestType Type
	RSSType            Type
	XMLType            Type
	SVGType            Type
	TextType           Type
	TOMLType           Type
	YAMLType           Type

	// Common image types
	PNGType  Type
	JPEGType Type
	GIFType  Type
	TIFFType Type
	BMPType  Type
	WEBPType Type

	// Common font types
	TrueTypeFontType Type
	OpenTypeFontType Type

	// Common document types
	PDFType      Type
	MarkdownType Type

	// Common video types
	AVIType  Type
	MPEGType Type
	MP4Type  Type
	OGGType  Type
	WEBMType Type
	GPPType  Type

	// wasm
	WasmType Type

	OctetType Type
}

var Builtin = BuiltinTypes{
	CalendarType:   Type{Type: "text/calendar"},
	CSSType:        Type{Type: "text/css"},
	SCSSType:       Type{Type: "text/x-scss"},
	SASSType:       Type{Type: "text/x-sass"},
	CSVType:        Type{Type: "text/csv"},
	HTMLType:       Type{Type: "text/html"},
	JavascriptType: Type{Type: "text/javascript"},
	TypeScriptType: Type{Type: "text/typescript"},
	TSXType:        Type{Type: "text/tsx"},
	JSXType:        Type{Type: "text/jsx"},

	JSONType:           Type{Type: "application/json"},
	WebAppManifestType: Type{Type: "application/manifest+json"},
	RSSType:            Type{Type: "application/rss+xml"},
	XMLType:            Type{Type: "application/xml"},
	SVGType:            Type{Type: "image/svg+xml"},
	TextType:           Type{Type: "text/plain"},
	TOMLType:           Type{Type: "application/toml"},
	YAMLType:           Type{Type: "application/yaml"},

	// Common image types
	PNGType:  Type{Type: "image/png"},
	JPEGType: Type{Type: "image/jpeg"},
	GIFType:  Type{Type: "image/gif"},
	TIFFType: Type{Type: "image/tiff"},
	BMPType:  Type{Type: "image/bmp"},
	WEBPType: Type{Type: "image/webp"},

	// Common font types
	TrueTypeFontType: Type{Type: "font/ttf"},
	OpenTypeFontType: Type{Type: "font/otf"},

	// Common document types
	PDFType:      Type{Type: "application/pdf"},
	MarkdownType: Type{Type: "text/markdown"},

	// Common video types
	AVIType:  Type{Type: "video/x-msvideo"},
	MPEGType: Type{Type: "video/mpeg"},
	MP4Type:  Type{Type: "video/mp4"},
	OGGType:  Type{Type: "video/ogg"},
	WEBMType: Type{Type: "video/webm"},
	GPPType:  Type{Type: "video/3gpp"},

	// Web assembly.
	WasmType: Type{Type: "application/wasm"},

	OctetType: Type{Type: "application/octet-stream"},
}

var defaultMediaTypesConfig = map[string]any{
	"text/calendar":   map[string]any{"suffixes": []string{"ics"}},
	"text/css":        map[string]any{"suffixes": []string{"css"}},
	"text/x-scss":     map[string]any{"suffixes": []string{"scss"}},
	"text/x-sass":     map[string]any{"suffixes": []string{"sass"}},
	"text/csv":        map[string]any{"suffixes": []string{"csv"}},
	"text/html":       map[string]any{"suffixes": []string{"html"}},
	"text/javascript": map[string]any{"suffixes": []string{"js", "jsm", "mjs"}},
	"text/typescript": map[string]any{"suffixes": []string{"ts"}},
	"text/tsx":        map[string]any{"suffixes": []string{"tsx"}},
	"text/jsx":        map[string]any{"suffixes": []string{"jsx"}},

	"application/json":          map[string]any{"suffixes": []string{"json"}},
	"application/manifest+json": map[string]any{"suffixes": []string{"webmanifest"}},
	"application/rss+xml":       map[string]any{"suffixes": []string{"xml", "rss"}},
	"application/xml":           map[string]any{"suffixes": []string{"xml"}},
	"image/svg+xml":             map[string]any{"suffixes": []string{"svg"}},
	"text/plain":                map[string]any{"suffixes": []string{"txt"}},
	"application/toml":          map[string]any{"suffixes": []string{"toml"}},
	"application/yaml":          map[string]any{"suffixes": []string{"yaml", "yml"}},

	// Common image types
	"image/png":  map[string]any{"suffixes": []string{"png"}},
	"image/jpeg": map[string]any{"suffixes": []string{"jpg", "jpeg", "jpe", "jif", "jfif"}},
	"image/gif":  map[string]any{"suffixes": []string{"gif"}},
	"image/tiff": map[string]any{"suffixes": []string{"tif", "tiff"}},
	"image/bmp":  map[string]any{"suffixes": []string{"bmp"}},
	"image/webp": map[string]any{"suffixes": []string{"webp"}},

	// Common font types
	"font/ttf": map[string]any{"suffixes": []string{"ttf"}},
	"font/otf": map[string]any{"suffixes": []string{"otf"}},

	// Common document types
	"application/pdf": map[string]any{"suffixes": []string{"pdf"}},
	"text/markdown":   map[string]any{"suffixes": []string{"md", "markdown"}},

	// Common video types
	"video/x-msvideo": map[string]any{"suffixes": []string{"avi"}},
	"video/mpeg":      map[string]any{"suffixes": []string{"mpg", "mpeg"}},
	"video/mp4":       map[string]any{"suffixes": []string{"mp4"}},
	"video/ogg":       map[string]any{"suffixes": []string{"ogv"}},
	"video/webm":      map[string]any{"suffixes": []string{"webm"}},
	"video/3gpp":      map[string]any{"suffixes": []string{"3gpp", "3gp"}},

	// wasm
	"application/wasm": map[string]any{"suffixes": []string{"wasm"}},

	"application/octet-stream": map[string]any{},
}

func init() {
	// Apply delimiter to all.
	for _, m := range defaultMediaTypesConfig {
		m.(map[string]any)["delimiter"] = "."
	}
}