Add ThreeMfDef FileDef subclass for 3MF (3D printing) files - #5628
Closed
FadhlanR wants to merge 1 commit into
Closed
Add ThreeMfDef FileDef subclass for 3MF (3D printing) files#5628FadhlanR wants to merge 1 commit into
FadhlanR wants to merge 1 commit into
Conversation
Index .3mf files as a first-class file type. 3MF is an OPC (ZIP) package whose 3dmodel.model XML carries title/designer/description/license and a unit — searchable text that is absent from the filename — so the subclass extracts it for full-text search. A bounded parse (inflate only the model part, read the header up to the geometry) keeps extractAttributes cheap on the indexing hot path; malformed files throw FileContentMismatchError and fall back to a bare FileDef. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Preview deploymentsHost Test Results 1 files 1 suites 2h 37m 26s ⏱️ Results for commit 9de70cd. For more details on these errors, see this check. Realm Server Test Results 1 files 1 suites 10m 49s ⏱️ Results for commit 9de70cd. |
Contributor
Author
|
[Claude Code 🤖] Superseded by #5658, which unifies StlDef (CS-12053) and ThreeMfDef (CS-12054) under a shared |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background and Goal
Adds
ThreeMfDef, aFileDefsubclass for.3mf(3D Manufacturing Format / 3D printing) files, so they index as a first-class file type. A.3mfis an OPC package (a ZIP) whose3D/3dmodel.modelXML carriestitle/designer/description/licenseand aunit— searchable text that is not present in the filename — so the subclass extracts it and feeds it into full-text search. Distinct icon + light metadata templates; no 3D viewer.Resolves CS-12054.
Where to start
packages/base/3mf-meta-extractor.ts— the parse.fflate.unzipSyncwith afilterthat records every entry name (→hasThumbnail) while inflating only the*.modelpart; then decodes ≤256 KB of the model, cuts at<resources>/<build>, and regex-extracts the metadata +unit. ThrowsFileContentMismatchErroron a non-ZIP or a ZIP with no model part.packages/base/3mf-file-def.gts—ThreeMfDef extends FileDef: the six searchable fields,extractAttributes(super+extract3mfMetadata),cube-3d-sphereicon,acceptTypes, and metadata-displayisolated/embeddedtemplates.packages/runtime-common/file-def-code-ref.ts— the one-line registry entry that maps.3mf → ThreeMfDefand lights upurlNamesFile/isFileDefCodeRef.Key decisions and non-obvious mechanics
extractAttributesruns for every file during the index/prerender visit and 3MF files can be large, so we inflate only the model part and cap the XML parse at the header (metadata lives above<resources>; geometry lives below). Counting objects/triangles or reading the bounding box would require scanning past all vertices, so those are deferred.FileContentMismatchError, so the extractor falls back to a bareFileDefand the file still indexes — same pattern asMp3Def/PngDef.fflate(~8 KB, isomorphic, added to the catalog +base). No ZIP/deflate library existed in the repo;basealready imports npm runtime deps this way (super-fast-md5,awesome-phonenumber). Also added tohostso the acceptance test can build fixtures..3mf → model/3mf(IANA-registered;mime-dbhas no entry) and classified binary, so the CLI/bot don't treat the ZIP as text.