Skip to content

Commit

Permalink
Add support for 3mf (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ugzuzg committed Jan 12, 2021
1 parent 579f8cb commit 7f95cd2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions core.d.ts
Expand Up @@ -136,7 +136,8 @@ declare namespace core {
| 'pgp'
| 'asar'
| 'stl'
| 'chm';
| 'chm'
| '3mf';

type MimeType =
| 'image/jpeg'
Expand Down Expand Up @@ -266,7 +267,8 @@ declare namespace core {
| 'application/pgp-encrypted'
| 'application/x-asar'
| 'model/stl'
| 'application/vnd.ms-htmlhelp';
| 'application/vnd.ms-htmlhelp'
| 'model/3mf';

interface FileTypeResult {
/**
Expand Down
7 changes: 7 additions & 0 deletions core.js
Expand Up @@ -318,6 +318,13 @@ async function _fromTokenizer(tokenizer) {
};
}

if (zipHeader.filename.startsWith('3D/') && zipHeader.filename.endsWith('.model')) {
return {
ext: '3mf',
mime: 'model/3mf'
};
}

// The docx, xlsx and pptx file types extend the Office Open XML file format:
// https://en.wikipedia.org/wiki/Office_Open_XML_file_formats
// We look for:
Expand Down
Binary file added fixture/fixture.3mf
Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -180,7 +180,8 @@
"pgp",
"asar",
"stl",
"chm"
"chm",
"3mf"
],
"devDependencies": {
"@types/node": "^13.1.4",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Expand Up @@ -405,6 +405,7 @@ Returns a set of supported MIME types.
- [`asar`](https://github.com/electron/asar#format) - Archive format primarily used to enclose Electron applications
- [`stl`](https://en.wikipedia.org/wiki/STL_(file_format)) - Standard Tesselated Geometry File Format (ASCII only)
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
- [`3mf`](https://en.wikipedia.org/wiki/3D_Manufacturing_Format) - 3D Manufacturing Format

*Pull requests are welcome for additional commonly used file types.*

Expand Down
6 changes: 4 additions & 2 deletions supported.js
Expand Up @@ -134,7 +134,8 @@ module.exports = {
'pgp',
'asar',
'stl',
'chm'
'chm',
'3mf'
],
mimeTypes: [
'image/jpeg',
Expand Down Expand Up @@ -264,6 +265,7 @@ module.exports = {
'application/pgp-encrypted',
'application/x-asar',
'model/stl',
'application/vnd.ms-htmlhelp'
'application/vnd.ms-htmlhelp',
'model/3mf'
]
};

0 comments on commit 7f95cd2

Please sign in to comment.