mime-types-no-nodejs 0.9.2 → 1.0.0

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/README.md CHANGED
@@ -78,4 +78,20 @@ Testing code snippet:
78
78
  it('type2mime', () => {
79
79
  assert.equal(Mime.lookup('png'), 'image/png');
80
80
  });
81
- ```
81
+ ```
82
+
83
+ # Types (since 0.10.0)
84
+
85
+ The types are in [db.json](db.json), in [mime-db](https://github.com/jshttp/mime-db)'s shape
86
+ (source, charset, compressible, extensions; the first extension is the type's default), but
87
+ only those of Anclient / Portfolio files: documents, archives, images, video, audio, and
88
+ semantic-doc's committed docs:
89
+
90
+ | type | extension | what |
91
+ |---|---|---|
92
+ | application/vnd.semantic-doc.html+zip | sdoc | a doc tree's html package |
93
+ | application/vnd.semantic-doc.story+json | story | a committed story's page |
94
+
95
+ A type not listed answers undefined, as an unknown type always did. Add a type to db.json
96
+ when a new kind of file is uploaded or committed. 0.9.x imported the whole mime-db (157 KiB,
97
+ ~2,000 types) into every bundle.
package/db.json ADDED
@@ -0,0 +1,428 @@
1
+ {
2
+ "//": {
3
+ "note": "The types of Anclient / Portfolio files only, in mime-db's shape (jshttp/mime-db: source, charset, compressible, extensions; the first extension is the type's default). Add a type here when a new kind of file is uploaded or committed; the vnd.semantic-doc types are semantic-doc's committed docs."
4
+ },
5
+ "application/vnd.semantic-doc.html+zip": {
6
+ "compressible": false,
7
+ "extensions": [
8
+ "sdoc"
9
+ ]
10
+ },
11
+ "application/vnd.semantic-doc.story+json": {
12
+ "charset": "UTF-8",
13
+ "compressible": true,
14
+ "extensions": [
15
+ "story"
16
+ ]
17
+ },
18
+ "application/pdf": {
19
+ "source": "iana",
20
+ "compressible": false,
21
+ "extensions": [
22
+ "pdf"
23
+ ]
24
+ },
25
+ "application/msword": {
26
+ "source": "iana",
27
+ "compressible": false,
28
+ "extensions": [
29
+ "doc",
30
+ "dot"
31
+ ]
32
+ },
33
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
34
+ "source": "iana",
35
+ "compressible": false,
36
+ "extensions": [
37
+ "docx"
38
+ ]
39
+ },
40
+ "application/vnd.ms-excel": {
41
+ "source": "iana",
42
+ "compressible": false,
43
+ "extensions": [
44
+ "xls",
45
+ "xlm",
46
+ "xla",
47
+ "xlc",
48
+ "xlt",
49
+ "xlw"
50
+ ]
51
+ },
52
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
53
+ "source": "iana",
54
+ "compressible": false,
55
+ "extensions": [
56
+ "xlsx"
57
+ ]
58
+ },
59
+ "application/vnd.ms-powerpoint": {
60
+ "source": "iana",
61
+ "compressible": false,
62
+ "extensions": [
63
+ "ppt",
64
+ "pps",
65
+ "pot"
66
+ ]
67
+ },
68
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": {
69
+ "source": "iana",
70
+ "compressible": false,
71
+ "extensions": [
72
+ "pptx"
73
+ ]
74
+ },
75
+ "application/rtf": {
76
+ "source": "iana",
77
+ "compressible": true,
78
+ "extensions": [
79
+ "rtf"
80
+ ]
81
+ },
82
+ "application/json": {
83
+ "source": "iana",
84
+ "charset": "UTF-8",
85
+ "compressible": true,
86
+ "extensions": [
87
+ "json",
88
+ "map"
89
+ ]
90
+ },
91
+ "application/xml": {
92
+ "source": "iana",
93
+ "compressible": true,
94
+ "extensions": [
95
+ "xml",
96
+ "xsl",
97
+ "xsd",
98
+ "rng"
99
+ ]
100
+ },
101
+ "text/plain": {
102
+ "source": "iana",
103
+ "compressible": true,
104
+ "extensions": [
105
+ "txt",
106
+ "text",
107
+ "conf",
108
+ "def",
109
+ "list",
110
+ "log",
111
+ "in",
112
+ "ini"
113
+ ]
114
+ },
115
+ "text/csv": {
116
+ "source": "iana",
117
+ "compressible": true,
118
+ "extensions": [
119
+ "csv"
120
+ ]
121
+ },
122
+ "text/markdown": {
123
+ "source": "iana",
124
+ "compressible": true,
125
+ "extensions": [
126
+ "md",
127
+ "markdown"
128
+ ]
129
+ },
130
+ "text/x-rst": {
131
+ "compressible": true,
132
+ "extensions": [
133
+ "rst"
134
+ ]
135
+ },
136
+ "text/html": {
137
+ "source": "iana",
138
+ "compressible": true,
139
+ "extensions": [
140
+ "html",
141
+ "htm",
142
+ "shtml"
143
+ ]
144
+ },
145
+ "text/css": {
146
+ "source": "iana",
147
+ "charset": "UTF-8",
148
+ "compressible": true,
149
+ "extensions": [
150
+ "css"
151
+ ]
152
+ },
153
+ "application/zip": {
154
+ "source": "iana",
155
+ "compressible": false,
156
+ "extensions": [
157
+ "zip"
158
+ ]
159
+ },
160
+ "application/x-7z-compressed": {
161
+ "source": "apache",
162
+ "compressible": false,
163
+ "extensions": [
164
+ "7z"
165
+ ]
166
+ },
167
+ "application/x-rar-compressed": {
168
+ "source": "apache",
169
+ "compressible": false,
170
+ "extensions": [
171
+ "rar"
172
+ ]
173
+ },
174
+ "application/gzip": {
175
+ "source": "iana",
176
+ "compressible": false,
177
+ "extensions": [
178
+ "gz"
179
+ ]
180
+ },
181
+ "application/x-tar": {
182
+ "source": "apache",
183
+ "compressible": true,
184
+ "extensions": [
185
+ "tar"
186
+ ]
187
+ },
188
+ "application/vnd.android.package-archive": {
189
+ "source": "apache",
190
+ "compressible": false,
191
+ "extensions": [
192
+ "apk"
193
+ ]
194
+ },
195
+ "application/octet-stream": {
196
+ "source": "iana",
197
+ "compressible": false,
198
+ "extensions": [
199
+ "bin",
200
+ "dms",
201
+ "lrf",
202
+ "mar",
203
+ "so",
204
+ "dist",
205
+ "distz",
206
+ "pkg",
207
+ "bpk",
208
+ "dump",
209
+ "elc",
210
+ "deploy",
211
+ "exe",
212
+ "dll",
213
+ "deb",
214
+ "dmg",
215
+ "iso",
216
+ "img",
217
+ "msi",
218
+ "msp",
219
+ "msm",
220
+ "buffer"
221
+ ]
222
+ },
223
+ "image/jpeg": {
224
+ "source": "iana",
225
+ "compressible": false,
226
+ "extensions": [
227
+ "jpeg",
228
+ "jpg",
229
+ "jpe"
230
+ ]
231
+ },
232
+ "image/png": {
233
+ "source": "iana",
234
+ "compressible": false,
235
+ "extensions": [
236
+ "png"
237
+ ]
238
+ },
239
+ "image/gif": {
240
+ "source": "iana",
241
+ "compressible": false,
242
+ "extensions": [
243
+ "gif"
244
+ ]
245
+ },
246
+ "image/webp": {
247
+ "source": "iana",
248
+ "compressible": false,
249
+ "extensions": [
250
+ "webp"
251
+ ]
252
+ },
253
+ "image/bmp": {
254
+ "source": "iana",
255
+ "compressible": true,
256
+ "extensions": [
257
+ "bmp",
258
+ "dib"
259
+ ]
260
+ },
261
+ "image/svg+xml": {
262
+ "source": "iana",
263
+ "compressible": true,
264
+ "extensions": [
265
+ "svg",
266
+ "svgz"
267
+ ]
268
+ },
269
+ "image/tiff": {
270
+ "source": "iana",
271
+ "compressible": false,
272
+ "extensions": [
273
+ "tif",
274
+ "tiff"
275
+ ]
276
+ },
277
+ "image/heic": {
278
+ "source": "iana",
279
+ "compressible": false,
280
+ "extensions": [
281
+ "heic"
282
+ ]
283
+ },
284
+ "image/heif": {
285
+ "source": "iana",
286
+ "compressible": false,
287
+ "extensions": [
288
+ "heif"
289
+ ]
290
+ },
291
+ "image/avif": {
292
+ "source": "iana",
293
+ "compressible": false,
294
+ "extensions": [
295
+ "avif"
296
+ ]
297
+ },
298
+ "image/x-icon": {
299
+ "source": "apache",
300
+ "compressible": true,
301
+ "extensions": [
302
+ "ico"
303
+ ]
304
+ },
305
+ "video/mp4": {
306
+ "source": "iana",
307
+ "compressible": false,
308
+ "extensions": [
309
+ "mp4",
310
+ "mp4v",
311
+ "mpg4"
312
+ ]
313
+ },
314
+ "video/quicktime": {
315
+ "source": "iana",
316
+ "compressible": false,
317
+ "extensions": [
318
+ "qt",
319
+ "mov"
320
+ ]
321
+ },
322
+ "video/webm": {
323
+ "source": "apache",
324
+ "compressible": false,
325
+ "extensions": [
326
+ "webm"
327
+ ]
328
+ },
329
+ "video/x-matroska": {
330
+ "source": "apache",
331
+ "compressible": false,
332
+ "extensions": [
333
+ "mkv",
334
+ "mk3d",
335
+ "mks"
336
+ ]
337
+ },
338
+ "video/3gpp": {
339
+ "source": "iana",
340
+ "compressible": false,
341
+ "extensions": [
342
+ "3gp",
343
+ "3gpp"
344
+ ]
345
+ },
346
+ "video/x-msvideo": {
347
+ "source": "apache",
348
+ "compressible": false,
349
+ "extensions": [
350
+ "avi"
351
+ ]
352
+ },
353
+ "video/mpeg": {
354
+ "source": "iana",
355
+ "compressible": false,
356
+ "extensions": [
357
+ "mpeg",
358
+ "mpg",
359
+ "mpe",
360
+ "m1v",
361
+ "m2v"
362
+ ]
363
+ },
364
+ "audio/mpeg": {
365
+ "source": "iana",
366
+ "compressible": false,
367
+ "extensions": [
368
+ "mpga",
369
+ "mp2",
370
+ "mp2a",
371
+ "mp3",
372
+ "m2a",
373
+ "m3a"
374
+ ]
375
+ },
376
+ "audio/mp4": {
377
+ "source": "iana",
378
+ "compressible": false,
379
+ "extensions": [
380
+ "m4a",
381
+ "mp4a"
382
+ ]
383
+ },
384
+ "audio/aac": {
385
+ "source": "iana",
386
+ "compressible": false,
387
+ "extensions": [
388
+ "aac"
389
+ ]
390
+ },
391
+ "audio/ogg": {
392
+ "source": "iana",
393
+ "compressible": false,
394
+ "extensions": [
395
+ "oga",
396
+ "ogg",
397
+ "spx",
398
+ "opus"
399
+ ]
400
+ },
401
+ "audio/wav": {
402
+ "compressible": false,
403
+ "extensions": [
404
+ "wav"
405
+ ]
406
+ },
407
+ "audio/webm": {
408
+ "source": "apache",
409
+ "compressible": false,
410
+ "extensions": [
411
+ "weba"
412
+ ]
413
+ },
414
+ "audio/x-flac": {
415
+ "source": "apache",
416
+ "compressible": false,
417
+ "extensions": [
418
+ "flac"
419
+ ]
420
+ },
421
+ "audio/amr": {
422
+ "source": "iana",
423
+ "compressible": false,
424
+ "extensions": [
425
+ "amr"
426
+ ]
427
+ }
428
+ }
package/index.ts CHANGED
@@ -8,7 +8,11 @@
8
8
  * MIT Licensed
9
9
  */
10
10
 
11
- import db from 'mime-db';
11
+ /**
12
+ * The types known, in mime-db's shape: only those of Anclient / Portfolio files, and the
13
+ * types of semantic-doc's committed docs (since 0.10.0; mime-db before, the full database).
14
+ */
15
+ import db from './db.json';
12
16
 
13
17
  function extname(pth) {
14
18
  let reg = /\.([\w\d]+)\s*$/;
@@ -40,7 +44,7 @@ function populateMaps (extensions: object, types: object) {
40
44
  let preference = ['nginx', 'apache', undefined, 'iana']
41
45
 
42
46
  Object.keys(db).forEach(function forEachMimeType (type) {
43
- let mime = db[type]
47
+ let mime = db[type] as { source?: string, extensions?: string[] }
44
48
  let exts = mime.extensions
45
49
 
46
50
  if (!exts || !exts.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mime-types-no-nodejs",
3
- "version": "0.9.2",
3
+ "version": "1.0.0",
4
4
  "description": "Typescript mime types to doc type mapping.",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -16,16 +16,9 @@
16
16
  "homepage": "https://github.com/odys-z/Mime-type-no-nodejs/blob/main/README.md",
17
17
  "devDependencies": {
18
18
  "@babel/preset-typescript": "^7.15.0",
19
- "@types/mime-db": "^1.43.1",
20
- "@types/node": "^16.10.9",
21
- "babel-loader": "^8.2.3",
22
19
  "chai": "^4.3.4",
23
20
  "mocha": "^9.1.3",
24
21
  "typescript": "^4.4.4",
25
22
  "webpack-cli": "^4.9.1"
26
- },
27
- "dependencies": {
28
- "@babel/preset-env": "^7.16.0",
29
- "mime-db": "^1.50.0"
30
23
  }
31
24
  }
package/test/no-node.ts CHANGED
@@ -11,4 +11,24 @@ describe('[case 1. regex]', () => {
11
11
  it('type2mime', () => {
12
12
  assert.equal(Mime.lookup('png'), 'image/png', '00.2 image/png');
13
13
  });
14
+
15
+ it('documents', () => {
16
+ assert.equal(Mime.extension('application/vnd.openxmlformats-officedocument.wordprocessingml.document'), 'docx', '2.1 docx');
17
+ assert.equal(Mime.extension('application/pdf'), 'pdf', '2.2 pdf');
18
+ assert.equal(Mime.extension('text/plain; charset=utf-8'), 'txt', '2.3 txt');
19
+ assert.equal(Mime.lookup('mp3'), 'audio/mpeg', '2.4 mp3');
20
+ assert.equal(Mime.lookup('mov'), 'video/quicktime', '2.5 mov');
21
+ });
22
+
23
+ it('semantic-doc', () => {
24
+ assert.equal(Mime.extension('application/vnd.semantic-doc.html+zip'), 'sdoc', '3.1 html package');
25
+ assert.equal(Mime.extension('application/vnd.semantic-doc.story+json'), 'story', '3.2 story page');
26
+ assert.equal(Mime.lookup('sdoc'), 'application/vnd.semantic-doc.html+zip', '3.3 sdoc');
27
+ assert.equal(Mime.lookup('story'), 'application/vnd.semantic-doc.story+json', '3.4 story');
28
+ });
29
+
30
+ it('unknown', () => {
31
+ assert.isUndefined(Mime.extension('application/x-not-listed'), '4.1 not in db.json');
32
+ assert.isUndefined(Mime.lookup('xyz'), '4.2 not in db.json');
33
+ });
14
34
  });
package/tsconfig.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "types": ["node"],
4
3
  "allowJs": true,
5
4
  // Generate d.ts files
6
5
  "declaration": true,
7
6
  "experimentalDecorators": true,
8
7
  "allowSyntheticDefaultImports": true,
9
8
  "esModuleInterop": true,
9
+ "resolveJsonModule": true,
10
10
  "outDir": "dist"
11
11
  },
12
12
  "exclude": [