brep-io-kernel 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/LICENSE.md +32 -0
- package/README.md +144 -0
- package/dist-kernel/brep-kernel.js +74699 -0
- package/dist-kernel/help/CONTRIBUTING.html +248 -0
- package/dist-kernel/help/LICENSE.html +248 -0
- package/dist-kernel/help/MODELING.png +0 -0
- package/dist-kernel/help/PMI.png +0 -0
- package/dist-kernel/help/SKETCH.png +0 -0
- package/dist-kernel/help/assembly-constraints__Coincident_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Angle_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Distance_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Fixed_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Parallel_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints___Touch_Align_Constraint_dialog.png +0 -0
- package/dist-kernel/help/assembly-constraints__angle-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__coincident-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__distance-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__fixed-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__parallel-constraint.html +248 -0
- package/dist-kernel/help/assembly-constraints__solver.html +248 -0
- package/dist-kernel/help/assembly-constraints__touch-align-constraint.html +248 -0
- package/dist-kernel/help/brep-api.html +263 -0
- package/dist-kernel/help/brep-kernel.html +258 -0
- package/dist-kernel/help/brep-model.html +248 -0
- package/dist-kernel/help/cylindrical-face-radius-embedding.html +290 -0
- package/dist-kernel/help/dialog-screenshots.html +248 -0
- package/dist-kernel/help/extruded-sketch-radius-embedding.html +336 -0
- package/dist-kernel/help/features__Assembly_Component_dialog.png +0 -0
- package/dist-kernel/help/features__Boolean_dialog.png +0 -0
- package/dist-kernel/help/features__Chamfer_dialog.png +0 -0
- package/dist-kernel/help/features__Datium_dialog.png +0 -0
- package/dist-kernel/help/features__Extrude_dialog.png +0 -0
- package/dist-kernel/help/features__Fillet_dialog.png +0 -0
- package/dist-kernel/help/features__Helix_dialog.png +0 -0
- package/dist-kernel/help/features__Hole_dialog.png +0 -0
- package/dist-kernel/help/features__Image_Heightmap_Solid_dialog.png +0 -0
- package/dist-kernel/help/features__Image_to_Face_dialog.png +0 -0
- package/dist-kernel/help/features__Import_3D_Model_dialog.png +0 -0
- package/dist-kernel/help/features__Loft_dialog.png +0 -0
- package/dist-kernel/help/features__Mirror_dialog.png +0 -0
- package/dist-kernel/help/features__Offset_Shell_dialog.png +0 -0
- package/dist-kernel/help/features__Overlap_Cleanup_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_Linear_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_Radial_dialog.png +0 -0
- package/dist-kernel/help/features__Pattern_dialog.png +0 -0
- package/dist-kernel/help/features__Plane_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cone_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cube_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Cylinder_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Pyramid_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Sphere_dialog.png +0 -0
- package/dist-kernel/help/features__Primitive_Torus_dialog.png +0 -0
- package/dist-kernel/help/features__Remesh_dialog.png +0 -0
- package/dist-kernel/help/features__Revolve_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Contour_Flange_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Cutout_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Flange_dialog.png +0 -0
- package/dist-kernel/help/features__Sheet_Metal_Tab_dialog.png +0 -0
- package/dist-kernel/help/features__Sketch_dialog.png +0 -0
- package/dist-kernel/help/features__Spline_dialog.png +0 -0
- package/dist-kernel/help/features__Sweep_dialog.png +0 -0
- package/dist-kernel/help/features__Transform_dialog.png +0 -0
- package/dist-kernel/help/features__Tube_dialog.png +0 -0
- package/dist-kernel/help/features__assembly-component.html +248 -0
- package/dist-kernel/help/features__boolean.html +248 -0
- package/dist-kernel/help/features__chamfer.html +248 -0
- package/dist-kernel/help/features__datium.html +248 -0
- package/dist-kernel/help/features__datum.html +248 -0
- package/dist-kernel/help/features__extrude.html +248 -0
- package/dist-kernel/help/features__fillet.html +248 -0
- package/dist-kernel/help/features__helix.html +248 -0
- package/dist-kernel/help/features__hole.html +248 -0
- package/dist-kernel/help/features__image-heightmap-solid.html +248 -0
- package/dist-kernel/help/features__image-to-face-2D_dialog.png +0 -0
- package/dist-kernel/help/features__image-to-face-3D_dialog.png +0 -0
- package/dist-kernel/help/features__image-to-face.html +248 -0
- package/dist-kernel/help/features__import-3d-model.html +248 -0
- package/dist-kernel/help/features__index.html +248 -0
- package/dist-kernel/help/features__loft.html +248 -0
- package/dist-kernel/help/features__mirror.html +248 -0
- package/dist-kernel/help/features__offset-shell.html +248 -0
- package/dist-kernel/help/features__pattern-linear.html +248 -0
- package/dist-kernel/help/features__pattern-radial.html +248 -0
- package/dist-kernel/help/features__pattern.html +248 -0
- package/dist-kernel/help/features__plane.html +248 -0
- package/dist-kernel/help/features__primitive-cone.html +248 -0
- package/dist-kernel/help/features__primitive-cube.html +248 -0
- package/dist-kernel/help/features__primitive-cylinder.html +248 -0
- package/dist-kernel/help/features__primitive-pyramid.html +248 -0
- package/dist-kernel/help/features__primitive-sphere.html +248 -0
- package/dist-kernel/help/features__primitive-torus.html +248 -0
- package/dist-kernel/help/features__remesh.html +248 -0
- package/dist-kernel/help/features__revolve.html +248 -0
- package/dist-kernel/help/features__sheet-metal-contour-flange.html +248 -0
- package/dist-kernel/help/features__sheet-metal-flange.html +248 -0
- package/dist-kernel/help/features__sheet-metal-tab.html +248 -0
- package/dist-kernel/help/features__sketch.html +248 -0
- package/dist-kernel/help/features__spline.html +248 -0
- package/dist-kernel/help/features__sweep.html +248 -0
- package/dist-kernel/help/features__transform.html +248 -0
- package/dist-kernel/help/features__tube.html +248 -0
- package/dist-kernel/help/file-formats.html +248 -0
- package/dist-kernel/help/getting-started.html +248 -0
- package/dist-kernel/help/highlights.html +248 -0
- package/dist-kernel/help/history-systems.html +248 -0
- package/dist-kernel/help/how-it-works.html +248 -0
- package/dist-kernel/help/index.html +862 -0
- package/dist-kernel/help/input-params-schema.html +363 -0
- package/dist-kernel/help/inspector-improvements.html +248 -0
- package/dist-kernel/help/inspector.html +248 -0
- package/dist-kernel/help/modes__modeling.html +248 -0
- package/dist-kernel/help/modes__pmi.html +248 -0
- package/dist-kernel/help/modes__sketch.html +248 -0
- package/dist-kernel/help/plugins.html +248 -0
- package/dist-kernel/help/pmi-annotations__Angle_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Explode_Body_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Hole_Callout_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Leader_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Linear_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Note_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__Radial_Dimension_dialog.png +0 -0
- package/dist-kernel/help/pmi-annotations__angle-dimension.html +248 -0
- package/dist-kernel/help/pmi-annotations__explode-body.html +248 -0
- package/dist-kernel/help/pmi-annotations__hole-callout.html +248 -0
- package/dist-kernel/help/pmi-annotations__index.html +248 -0
- package/dist-kernel/help/pmi-annotations__leader.html +248 -0
- package/dist-kernel/help/pmi-annotations__linear-dimension.html +248 -0
- package/dist-kernel/help/pmi-annotations__note.html +248 -0
- package/dist-kernel/help/pmi-annotations__radial-dimension.html +248 -0
- package/dist-kernel/help/search-index.json +464 -0
- package/dist-kernel/help/simplified-radial-dimensions.html +298 -0
- package/dist-kernel/help/solid-methods.html +359 -0
- package/dist-kernel/help/table-of-contents.html +330 -0
- package/dist-kernel/help/ui-overview.html +248 -0
- package/dist-kernel/help/whats-new.html +248 -0
- package/package.json +54 -0
- package/src/BREP/AssemblyComponent.js +42 -0
- package/src/BREP/BREP.js +43 -0
- package/src/BREP/BetterSolid.js +805 -0
- package/src/BREP/Edge.js +103 -0
- package/src/BREP/Extrude.js +403 -0
- package/src/BREP/Face.js +187 -0
- package/src/BREP/MeshRepairer.js +634 -0
- package/src/BREP/OffsetShellSolid.js +614 -0
- package/src/BREP/PointCloudWrap.js +302 -0
- package/src/BREP/Revolve.js +345 -0
- package/src/BREP/SolidMethods/authoring.js +112 -0
- package/src/BREP/SolidMethods/booleanOps.js +230 -0
- package/src/BREP/SolidMethods/chamfer.js +122 -0
- package/src/BREP/SolidMethods/edgeResolution.js +25 -0
- package/src/BREP/SolidMethods/fillet.js +792 -0
- package/src/BREP/SolidMethods/index.js +72 -0
- package/src/BREP/SolidMethods/io.js +105 -0
- package/src/BREP/SolidMethods/lifecycle.js +103 -0
- package/src/BREP/SolidMethods/manifoldOps.js +375 -0
- package/src/BREP/SolidMethods/meshCleanup.js +2512 -0
- package/src/BREP/SolidMethods/meshQueries.js +264 -0
- package/src/BREP/SolidMethods/metadata.js +106 -0
- package/src/BREP/SolidMethods/metrics.js +51 -0
- package/src/BREP/SolidMethods/transforms.js +361 -0
- package/src/BREP/SolidMethods/visualize.js +508 -0
- package/src/BREP/SolidShared.js +26 -0
- package/src/BREP/Sweep.js +1596 -0
- package/src/BREP/Tube.js +857 -0
- package/src/BREP/Vertex.js +43 -0
- package/src/BREP/applyBooleanOperation.js +704 -0
- package/src/BREP/boundsUtils.js +48 -0
- package/src/BREP/chamfer.js +551 -0
- package/src/BREP/edgePolylineUtils.js +85 -0
- package/src/BREP/fillets/common.js +388 -0
- package/src/BREP/fillets/fillet.js +1422 -0
- package/src/BREP/fillets/filletGeometry.js +15 -0
- package/src/BREP/fillets/inset.js +389 -0
- package/src/BREP/fillets/offsetHelper.js +143 -0
- package/src/BREP/fillets/outset.js +88 -0
- package/src/BREP/helix.js +193 -0
- package/src/BREP/meshToBrep.js +234 -0
- package/src/BREP/primitives.js +279 -0
- package/src/BREP/setupManifold.js +71 -0
- package/src/BREP/threadGeometry.js +1120 -0
- package/src/BREP/triangleUtils.js +8 -0
- package/src/BREP/triangulate.js +608 -0
- package/src/FeatureRegistry.js +183 -0
- package/src/PartHistory.js +1132 -0
- package/src/UI/AccordionWidget.js +292 -0
- package/src/UI/CADmaterials.js +850 -0
- package/src/UI/EnvMonacoEditor.js +522 -0
- package/src/UI/FloatingWindow.js +396 -0
- package/src/UI/HistoryWidget.js +457 -0
- package/src/UI/MainToolbar.js +131 -0
- package/src/UI/ModelLibraryView.js +194 -0
- package/src/UI/OrthoCameraIdle.js +206 -0
- package/src/UI/PluginsWidget.js +280 -0
- package/src/UI/SceneListing.js +606 -0
- package/src/UI/SelectionFilter.js +629 -0
- package/src/UI/ViewCube.js +389 -0
- package/src/UI/assembly/AssemblyConstraintCollectionWidget.js +329 -0
- package/src/UI/assembly/AssemblyConstraintControlsWidget.js +282 -0
- package/src/UI/assembly/AssemblyConstraintsWidget.css +292 -0
- package/src/UI/assembly/AssemblyConstraintsWidget.js +1373 -0
- package/src/UI/assembly/constraintFaceUtils.js +115 -0
- package/src/UI/assembly/constraintHighlightUtils.js +70 -0
- package/src/UI/assembly/constraintLabelUtils.js +31 -0
- package/src/UI/assembly/constraintPointUtils.js +64 -0
- package/src/UI/assembly/constraintSelectionUtils.js +185 -0
- package/src/UI/assembly/constraintStatusUtils.js +142 -0
- package/src/UI/componentSelectorModal.js +240 -0
- package/src/UI/controls/CombinedTransformControls.js +386 -0
- package/src/UI/dialogs.js +351 -0
- package/src/UI/expressionsManager.js +100 -0
- package/src/UI/featureDialogWidgets/booleanField.js +25 -0
- package/src/UI/featureDialogWidgets/booleanOperationField.js +97 -0
- package/src/UI/featureDialogWidgets/buttonField.js +45 -0
- package/src/UI/featureDialogWidgets/componentSelectorField.js +102 -0
- package/src/UI/featureDialogWidgets/defaultField.js +23 -0
- package/src/UI/featureDialogWidgets/fileField.js +66 -0
- package/src/UI/featureDialogWidgets/index.js +34 -0
- package/src/UI/featureDialogWidgets/numberField.js +165 -0
- package/src/UI/featureDialogWidgets/optionsField.js +33 -0
- package/src/UI/featureDialogWidgets/referenceSelectionField.js +208 -0
- package/src/UI/featureDialogWidgets/stringField.js +24 -0
- package/src/UI/featureDialogWidgets/textareaField.js +28 -0
- package/src/UI/featureDialogWidgets/threadDesignationField.js +160 -0
- package/src/UI/featureDialogWidgets/transformField.js +252 -0
- package/src/UI/featureDialogWidgets/utils.js +43 -0
- package/src/UI/featureDialogWidgets/vec3Field.js +133 -0
- package/src/UI/featureDialogs.js +1414 -0
- package/src/UI/fileManagerWidget.js +615 -0
- package/src/UI/history/HistoryCollectionWidget.js +1294 -0
- package/src/UI/history/historyCollectionWidget.css.js +257 -0
- package/src/UI/history/historyDisplayInfo.js +133 -0
- package/src/UI/mobile.js +28 -0
- package/src/UI/objectDump.js +442 -0
- package/src/UI/pmi/AnnotationCollectionWidget.js +120 -0
- package/src/UI/pmi/AnnotationHistory.js +353 -0
- package/src/UI/pmi/AnnotationRegistry.js +90 -0
- package/src/UI/pmi/BaseAnnotation.js +269 -0
- package/src/UI/pmi/LabelOverlay.css +102 -0
- package/src/UI/pmi/LabelOverlay.js +191 -0
- package/src/UI/pmi/PMIMode.js +1550 -0
- package/src/UI/pmi/PMIViewsWidget.js +1098 -0
- package/src/UI/pmi/annUtils.js +729 -0
- package/src/UI/pmi/dimensions/AngleDimensionAnnotation.js +647 -0
- package/src/UI/pmi/dimensions/ExplodeBodyAnnotation.js +507 -0
- package/src/UI/pmi/dimensions/HoleCalloutAnnotation.js +462 -0
- package/src/UI/pmi/dimensions/LeaderAnnotation.js +403 -0
- package/src/UI/pmi/dimensions/LinearDimensionAnnotation.js +532 -0
- package/src/UI/pmi/dimensions/NoteAnnotation.js +110 -0
- package/src/UI/pmi/dimensions/RadialDimensionAnnotation.js +659 -0
- package/src/UI/pmi/pmiStyle.js +44 -0
- package/src/UI/sketcher/SketchMode3D.js +4095 -0
- package/src/UI/sketcher/dimensions.js +674 -0
- package/src/UI/sketcher/glyphs.js +236 -0
- package/src/UI/sketcher/highlights.js +60 -0
- package/src/UI/toolbarButtons/aboutButton.js +5 -0
- package/src/UI/toolbarButtons/exportButton.js +609 -0
- package/src/UI/toolbarButtons/flatPatternButton.js +307 -0
- package/src/UI/toolbarButtons/importButton.js +160 -0
- package/src/UI/toolbarButtons/inspectorToggleButton.js +12 -0
- package/src/UI/toolbarButtons/metadataButton.js +1063 -0
- package/src/UI/toolbarButtons/orientToFaceButton.js +114 -0
- package/src/UI/toolbarButtons/registerDefaultButtons.js +46 -0
- package/src/UI/toolbarButtons/saveButton.js +99 -0
- package/src/UI/toolbarButtons/scriptRunnerButton.js +302 -0
- package/src/UI/toolbarButtons/testsButton.js +26 -0
- package/src/UI/toolbarButtons/undoRedoButtons.js +25 -0
- package/src/UI/toolbarButtons/wireframeToggleButton.js +5 -0
- package/src/UI/toolbarButtons/zoomToFitButton.js +5 -0
- package/src/UI/triangleDebuggerWindow.js +945 -0
- package/src/UI/viewer.js +4228 -0
- package/src/assemblyConstraints/AssemblyConstraintHistory.js +1576 -0
- package/src/assemblyConstraints/AssemblyConstraintRegistry.js +120 -0
- package/src/assemblyConstraints/BaseAssemblyConstraint.js +66 -0
- package/src/assemblyConstraints/constraintExpressionUtils.js +35 -0
- package/src/assemblyConstraints/constraintUtils/parallelAlignment.js +676 -0
- package/src/assemblyConstraints/constraints/AngleConstraint.js +485 -0
- package/src/assemblyConstraints/constraints/CoincidentConstraint.js +194 -0
- package/src/assemblyConstraints/constraints/DistanceConstraint.js +616 -0
- package/src/assemblyConstraints/constraints/FixedConstraint.js +78 -0
- package/src/assemblyConstraints/constraints/ParallelConstraint.js +252 -0
- package/src/assemblyConstraints/constraints/TouchAlignConstraint.js +961 -0
- package/src/core/entities/HistoryCollectionBase.js +72 -0
- package/src/core/entities/ListEntityBase.js +109 -0
- package/src/core/entities/schemaProcesser.js +121 -0
- package/src/exporters/sheetMetalFlatPattern.js +659 -0
- package/src/exporters/sheetMetalUnfold.js +862 -0
- package/src/exporters/step.js +1135 -0
- package/src/exporters/threeMF.js +575 -0
- package/src/features/assemblyComponent/AssemblyComponentFeature.js +780 -0
- package/src/features/boolean/BooleanFeature.js +94 -0
- package/src/features/chamfer/ChamferFeature.js +116 -0
- package/src/features/datium/DatiumFeature.js +80 -0
- package/src/features/edgeFeatureUtils.js +41 -0
- package/src/features/extrude/ExtrudeFeature.js +143 -0
- package/src/features/fillet/FilletFeature.js +197 -0
- package/src/features/helix/HelixFeature.js +405 -0
- package/src/features/hole/HoleFeature.js +1050 -0
- package/src/features/hole/screwClearance.js +86 -0
- package/src/features/hole/threadDesignationCatalog.js +149 -0
- package/src/features/imageHeightSolid/ImageHeightmapSolidFeature.js +463 -0
- package/src/features/imageToFace/ImageToFaceFeature.js +727 -0
- package/src/features/imageToFace/imageEditor.js +1270 -0
- package/src/features/imageToFace/traceUtils.js +971 -0
- package/src/features/import3dModel/Import3dModelFeature.js +151 -0
- package/src/features/loft/LoftFeature.js +605 -0
- package/src/features/mirror/MirrorFeature.js +151 -0
- package/src/features/offsetFace/OffsetFaceFeature.js +370 -0
- package/src/features/offsetShell/OffsetShellFeature.js +89 -0
- package/src/features/overlapCleanup/OverlapCleanupFeature.js +85 -0
- package/src/features/pattern/PatternFeature.js +275 -0
- package/src/features/patternLinear/PatternLinearFeature.js +120 -0
- package/src/features/patternRadial/PatternRadialFeature.js +186 -0
- package/src/features/plane/PlaneFeature.js +154 -0
- package/src/features/primitiveCone/primitiveConeFeature.js +99 -0
- package/src/features/primitiveCube/primitiveCubeFeature.js +70 -0
- package/src/features/primitiveCylinder/primitiveCylinderFeature.js +91 -0
- package/src/features/primitivePyramid/primitivePyramidFeature.js +72 -0
- package/src/features/primitiveSphere/primitiveSphereFeature.js +62 -0
- package/src/features/primitiveTorus/primitiveTorusFeature.js +109 -0
- package/src/features/remesh/RemeshFeature.js +97 -0
- package/src/features/revolve/RevolveFeature.js +111 -0
- package/src/features/selectionUtils.js +118 -0
- package/src/features/sheetMetal/SheetMetalContourFlangeFeature.js +1656 -0
- package/src/features/sheetMetal/SheetMetalCutoutFeature.js +1056 -0
- package/src/features/sheetMetal/SheetMetalFlangeFeature.js +1568 -0
- package/src/features/sheetMetal/SheetMetalHemFeature.js +43 -0
- package/src/features/sheetMetal/SheetMetalObject.js +141 -0
- package/src/features/sheetMetal/SheetMetalTabFeature.js +176 -0
- package/src/features/sheetMetal/UNFOLD_NEUTRAL_REQUIREMENTS.md +153 -0
- package/src/features/sheetMetal/contour-flange-rebuild-spec.md +261 -0
- package/src/features/sheetMetal/profileUtils.js +25 -0
- package/src/features/sheetMetal/sheetMetalCleanup.js +9 -0
- package/src/features/sheetMetal/sheetMetalFaceTypes.js +146 -0
- package/src/features/sheetMetal/sheetMetalMetadata.js +165 -0
- package/src/features/sheetMetal/sheetMetalPipeline.js +169 -0
- package/src/features/sheetMetal/sheetMetalProfileUtils.js +216 -0
- package/src/features/sheetMetal/sheetMetalTabUtils.js +29 -0
- package/src/features/sheetMetal/sheetMetalTree.js +210 -0
- package/src/features/sketch/SketchFeature.js +955 -0
- package/src/features/sketch/sketchSolver2D/ConstraintEngine.js +800 -0
- package/src/features/sketch/sketchSolver2D/constraintDefinitions.js +704 -0
- package/src/features/sketch/sketchSolver2D/mathHelpersMod.js +307 -0
- package/src/features/spline/SplineEditorSession.js +988 -0
- package/src/features/spline/SplineFeature.js +1388 -0
- package/src/features/spline/splineUtils.js +218 -0
- package/src/features/sweep/SweepFeature.js +110 -0
- package/src/features/transform/TransformFeature.js +152 -0
- package/src/features/tube/TubeFeature.js +635 -0
- package/src/fs.proxy.js +625 -0
- package/src/idbStorage.js +254 -0
- package/src/index.js +12 -0
- package/src/main.js +15 -0
- package/src/metadataManager.js +64 -0
- package/src/path.proxy.js +277 -0
- package/src/plugins/ghLoader.worker.js +151 -0
- package/src/plugins/pluginManager.js +286 -0
- package/src/pmi/PMIViewsManager.js +134 -0
- package/src/services/componentLibrary.js +198 -0
- package/src/tests/ConsoleCapture.js +189 -0
- package/src/tests/S7-diagnostics-2025-12-23T18-37-23-570Z.json +630 -0
- package/src/tests/browserTests.js +597 -0
- package/src/tests/debugBoolean.js +225 -0
- package/src/tests/partFiles/badBoolean.json +957 -0
- package/src/tests/partFiles/extrudeTest.json +88 -0
- package/src/tests/partFiles/filletFail.json +58 -0
- package/src/tests/partFiles/import_TEst.part.part.json +646 -0
- package/src/tests/partFiles/sheetMetalHem.BREP.json +734 -0
- package/src/tests/test_boolean_subtract.js +27 -0
- package/src/tests/test_chamfer.js +17 -0
- package/src/tests/test_extrudeFace.js +24 -0
- package/src/tests/test_fillet.js +17 -0
- package/src/tests/test_fillet_nonClosed.js +45 -0
- package/src/tests/test_filletsMoreDifficult.js +46 -0
- package/src/tests/test_history_features_basic.js +149 -0
- package/src/tests/test_hole.js +282 -0
- package/src/tests/test_mirror.js +16 -0
- package/src/tests/test_offsetShellGrouping.js +85 -0
- package/src/tests/test_plane.js +4 -0
- package/src/tests/test_primitiveCone.js +11 -0
- package/src/tests/test_primitiveCube.js +7 -0
- package/src/tests/test_primitiveCylinder.js +8 -0
- package/src/tests/test_primitivePyramid.js +9 -0
- package/src/tests/test_primitiveSphere.js +17 -0
- package/src/tests/test_primitiveTorus.js +21 -0
- package/src/tests/test_pushFace.js +126 -0
- package/src/tests/test_sheetMetalContourFlange.js +125 -0
- package/src/tests/test_sheetMetal_features.js +80 -0
- package/src/tests/test_sketch_openLoop.js +45 -0
- package/src/tests/test_solidMetrics.js +58 -0
- package/src/tests/test_stlLoader.js +1889 -0
- package/src/tests/test_sweepFace.js +55 -0
- package/src/tests/test_tube.js +45 -0
- package/src/tests/test_tube_closedLoop.js +67 -0
- package/src/tests/tests.js +493 -0
- package/src/tools/assemblyConstraintDialogCapturePage.js +56 -0
- package/src/tools/dialogCapturePageFactory.js +227 -0
- package/src/tools/featureDialogCapturePage.js +47 -0
- package/src/tools/pmiAnnotationDialogCapturePage.js +60 -0
- package/src/utils/axisHelpers.js +99 -0
- package/src/utils/deepClone.js +69 -0
- package/src/utils/geometryTolerance.js +37 -0
- package/src/utils/normalizeTypeString.js +8 -0
- package/src/utils/xformMath.js +51 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* generateObjectUI(obj, options?)
|
|
3
|
+
* - Renders a dark-mode, editable tree view for any JS object/array.
|
|
4
|
+
* - Edits update the original object immediately (by path).
|
|
5
|
+
* - Returns a root <div> you can attach anywhere.
|
|
6
|
+
*/
|
|
7
|
+
export function generateObjectUI(target, options = {}) {
|
|
8
|
+
ensureStyles();
|
|
9
|
+
const cfg = {
|
|
10
|
+
title: options.title ?? 'Object Inspector',
|
|
11
|
+
showTypes: options.showTypes ?? true,
|
|
12
|
+
collapseChildren: options.collapseChildren ?? options.collapsed ?? true,
|
|
13
|
+
maxPreview: options.maxPreview ?? 40, // preview length for summaries
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// Root container
|
|
17
|
+
const root = document.createElement('div');
|
|
18
|
+
root.className = 'objui';
|
|
19
|
+
|
|
20
|
+
// Header
|
|
21
|
+
const header = document.createElement('div');
|
|
22
|
+
header.className = 'objui-header';
|
|
23
|
+
|
|
24
|
+
const title = document.createElement('div');
|
|
25
|
+
title.className = 'objui-title';
|
|
26
|
+
title.textContent = cfg.title;
|
|
27
|
+
|
|
28
|
+
const search = document.createElement('div');
|
|
29
|
+
search.className = 'objui-search';
|
|
30
|
+
const searchInput = document.createElement('input');
|
|
31
|
+
searchInput.placeholder = 'Filter by key or path…';
|
|
32
|
+
search.appendChild(searchInput);
|
|
33
|
+
|
|
34
|
+
const actions = document.createElement('div');
|
|
35
|
+
actions.className = 'objui-actions';
|
|
36
|
+
const btnExpand = mkButton('Expand all');
|
|
37
|
+
const btnCollapse = mkButton('Collapse all');
|
|
38
|
+
const btnCopy = mkButton('Copy JSON');
|
|
39
|
+
actions.append(btnExpand, btnCollapse, btnCopy);
|
|
40
|
+
|
|
41
|
+
header.append(title, search, actions);
|
|
42
|
+
root.appendChild(header);
|
|
43
|
+
root.appendChild(hr());
|
|
44
|
+
|
|
45
|
+
// Tree
|
|
46
|
+
const tree = document.createElement('div');
|
|
47
|
+
tree.className = 'tree';
|
|
48
|
+
root.appendChild(tree);
|
|
49
|
+
|
|
50
|
+
// Build nodes
|
|
51
|
+
const state = { target, nodes: [] };
|
|
52
|
+
const top = buildNode(state, target, [], cfg);
|
|
53
|
+
tree.appendChild(top);
|
|
54
|
+
|
|
55
|
+
// Wire actions
|
|
56
|
+
btnExpand.addEventListener('click', () => setAllDetails(root, true));
|
|
57
|
+
btnCollapse.addEventListener('click', () => setAllDetails(root, false));
|
|
58
|
+
btnCopy.addEventListener('click', () => {
|
|
59
|
+
try {
|
|
60
|
+
const text = JSON.stringify(target, replacerForJSON(), 2);
|
|
61
|
+
navigator.clipboard.writeText(text);
|
|
62
|
+
pulse(btnCopy, 'Copied!');
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error(e);
|
|
65
|
+
alert('Failed to copy JSON.');
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Filtering
|
|
70
|
+
searchInput.addEventListener('input', () => filterTree(root, searchInput.value.trim().toLowerCase()));
|
|
71
|
+
|
|
72
|
+
return root;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* ========================= Helpers ========================= */
|
|
76
|
+
|
|
77
|
+
function ensureStyles() {
|
|
78
|
+
if (document.getElementById('objui-styles')) return;
|
|
79
|
+
const style = document.createElement('style');
|
|
80
|
+
style.id = 'objui-styles';
|
|
81
|
+
style.textContent = `
|
|
82
|
+
:root{ --bg:#0b0d10; --panel:#0f141a; --text:#e5e7eb; --muted:#9aa4b2; --border:#2a3442; --hover:#1b2433; --ok:#3b82f6; }
|
|
83
|
+
.objui{ color:var(--text); font:12px/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
|
|
84
|
+
.objui .hr{ height:1px; background:#1e2430; margin:6px 0; }
|
|
85
|
+
|
|
86
|
+
.objui-header{ display:grid; grid-template-columns: auto 1fr auto; align-items:center; gap:8px; }
|
|
87
|
+
.objui-title{ font-weight:700; color:var(--text); white-space:nowrap; }
|
|
88
|
+
.objui-search input{ width:100%; box-sizing:border-box; background:var(--panel); color:var(--text); border:1px solid var(--border); border-radius:6px; padding:6px 8px; font:12px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
|
|
89
|
+
.objui-actions{ display:flex; gap:6px; }
|
|
90
|
+
.objui-btn{ background:var(--hover); color:var(--text); border:1px solid var(--border); padding:6px 8px; border-radius:8px; cursor:pointer; font-weight:700; font-size:12px; }
|
|
91
|
+
.objui-btn:hover{ filter:brightness(1.1); }
|
|
92
|
+
|
|
93
|
+
.tree{ display:block; }
|
|
94
|
+
|
|
95
|
+
details{ border-left:1px solid #1e2430; margin-left:8px; }
|
|
96
|
+
summary{ list-style:none; cursor:pointer; user-select:none; padding:4px 4px; margin-left:-8px; display:grid; grid-template-columns:14px 1fr auto auto; align-items:center; gap:8px; color:var(--text); }
|
|
97
|
+
summary::-webkit-details-marker{ display:none; }
|
|
98
|
+
.chev{ width:14px; height:14px; color:#9aa4b2; transform:rotate(180deg); transition:transform .12s ease; }
|
|
99
|
+
details[open] > summary .chev{ transform:rotate(90deg); }
|
|
100
|
+
.key{ color:var(--text); font-weight:600; min-width:0; overflow:hidden; text-overflow:ellipsis; }
|
|
101
|
+
.meta{ color:var(--muted); font-style:italic; }
|
|
102
|
+
.type-badge{ color:#b7c0cc; border:1px solid #2d3748; border-radius:6px; padding:2px 6px; font:11px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
|
|
103
|
+
|
|
104
|
+
.kv{ display:grid; grid-template-columns:14px 180px 1fr auto; align-items:center; gap:8px; padding:4px 4px; }
|
|
105
|
+
.kv .key{ font-weight:600; }
|
|
106
|
+
.value-input, .value-date{ width:100%; box-sizing:border-box; background:var(--panel); color:var(--text); border:1px solid var(--border); border-radius:6px; padding:5px 7px; font:12px ui-monospace, Menlo, Consolas, monospace; }
|
|
107
|
+
.value-input.readonly, .value-date.readonly{ background:#0f141a; color:#c9d1d9; border-color:#1e2430; user-select:text; }
|
|
108
|
+
.value-checkbox{ width:16px; height:16px; }
|
|
109
|
+
|
|
110
|
+
.hidden{ display:none !important; }
|
|
111
|
+
`;
|
|
112
|
+
document.head.appendChild(style);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const isArray = Array.isArray;
|
|
116
|
+
const isDate = (v) => v instanceof Date || (typeof v === 'string' && !isNaN(Date.parse(v)) && /^\d{4}-\d{2}-\d{2}/.test(v));
|
|
117
|
+
const typeOf = (v) => {
|
|
118
|
+
if (v === null) return 'null';
|
|
119
|
+
if (isArray(v)) return 'array';
|
|
120
|
+
if (isDate(v)) return 'date';
|
|
121
|
+
return typeof v; // object, number, string, boolean, bigint, symbol, function, undefined
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
function mkButton(label) {
|
|
125
|
+
const b = document.createElement('button');
|
|
126
|
+
b.className = 'objui-btn';
|
|
127
|
+
b.textContent = label;
|
|
128
|
+
return b;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function hr() {
|
|
132
|
+
const d = document.createElement('div');
|
|
133
|
+
d.className = 'hr';
|
|
134
|
+
return d;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function pulse(btn, text) {
|
|
138
|
+
const prev = btn.textContent;
|
|
139
|
+
btn.textContent = text;
|
|
140
|
+
btn.style.borderColor = 'var(--ok)';
|
|
141
|
+
setTimeout(() => {
|
|
142
|
+
btn.textContent = prev;
|
|
143
|
+
btn.style.borderColor = 'var(--border)';
|
|
144
|
+
}, 900);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function setAllDetails(root, open) {
|
|
148
|
+
root.querySelectorAll('details').forEach(d => d.open = open);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function lockInputForCopy(inp) {
|
|
152
|
+
inp.readOnly = true;
|
|
153
|
+
inp.setAttribute('aria-readonly', 'true');
|
|
154
|
+
inp.classList.add('readonly');
|
|
155
|
+
inp.title = 'Read-only (select to copy)';
|
|
156
|
+
inp.addEventListener('wheel', (e) => e.preventDefault());
|
|
157
|
+
return inp;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function createChevron() {
|
|
161
|
+
const chev = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
162
|
+
chev.setAttribute('viewBox', '0 0 24 24');
|
|
163
|
+
chev.classList.add('chev');
|
|
164
|
+
const pathEl = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
165
|
+
pathEl.setAttribute('d', 'M15.5 19l-7-7 7-7');
|
|
166
|
+
pathEl.setAttribute('fill', 'none');
|
|
167
|
+
pathEl.setAttribute('stroke', 'currentColor');
|
|
168
|
+
pathEl.setAttribute('stroke-width', '2');
|
|
169
|
+
pathEl.setAttribute('stroke-linecap', 'round');
|
|
170
|
+
pathEl.setAttribute('stroke-linejoin', 'round');
|
|
171
|
+
chev.appendChild(pathEl);
|
|
172
|
+
return chev;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function buildSummaryRow(keyText, metaText, typeText, cfg) {
|
|
176
|
+
const summary = document.createElement('summary');
|
|
177
|
+
const keyEl = document.createElement('div');
|
|
178
|
+
keyEl.className = 'key';
|
|
179
|
+
keyEl.textContent = keyText;
|
|
180
|
+
const metaEl = document.createElement('div');
|
|
181
|
+
metaEl.className = 'meta';
|
|
182
|
+
metaEl.textContent = metaText;
|
|
183
|
+
const typeBadge = document.createElement('div');
|
|
184
|
+
typeBadge.className = 'type-badge';
|
|
185
|
+
typeBadge.textContent = typeText;
|
|
186
|
+
summary.append(createChevron(), keyEl, metaEl, cfg.showTypes ? typeBadge : document.createTextNode(''));
|
|
187
|
+
return { summary, metaEl };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function formatLazyKey(key) {
|
|
191
|
+
return key.replace(/^_lazy/, '').replace(/([A-Z])/g, ' $1').trim().toLowerCase() || key;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function shouldDetailsOpen(path, cfg) {
|
|
195
|
+
return path.length === 0 || !cfg.collapseChildren;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function filterTree(root, q) {
|
|
199
|
+
if (!q) {
|
|
200
|
+
root.querySelectorAll('.kv, details').forEach(el => el.classList.remove('hidden'));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
root.querySelectorAll('[data-path]').forEach(el => {
|
|
204
|
+
const key = el.getAttribute('data-key')?.toLowerCase() ?? '';
|
|
205
|
+
const path = el.getAttribute('data-path')?.toLowerCase() ?? '';
|
|
206
|
+
const hit = key.includes(q) || path.includes(q);
|
|
207
|
+
el.classList.toggle('hidden', !hit);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* JSON replacer to handle BigInt & Date gracefully
|
|
213
|
+
*/
|
|
214
|
+
function replacerForJSON() {
|
|
215
|
+
return (_, v) => {
|
|
216
|
+
if (typeof v === 'bigint') return v.toString() + 'n';
|
|
217
|
+
if (v instanceof Date) return v.toISOString();
|
|
218
|
+
return v;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Build a subtree for value at a path.
|
|
224
|
+
*/
|
|
225
|
+
function buildNode(state, value, path, cfg) {
|
|
226
|
+
const t = typeOf(value);
|
|
227
|
+
|
|
228
|
+
// Non-container types: render as key/value row (container handled by caller)
|
|
229
|
+
if (t !== 'object' && t !== 'array') {
|
|
230
|
+
return renderKV(state, path[path.length - 1] ?? '(root)', value, path, cfg);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Container: <details> with children
|
|
234
|
+
const details = document.createElement('details');
|
|
235
|
+
details.open = shouldDetailsOpen(path, cfg);
|
|
236
|
+
details.setAttribute('data-path', pathToString(path));
|
|
237
|
+
details.setAttribute('data-key', path[path.length - 1] ?? '');
|
|
238
|
+
const keyLabel = path.length ? String(path[path.length - 1]) : '(root)';
|
|
239
|
+
const keysForObject = t === 'object' ? Object.keys(value) : null;
|
|
240
|
+
const metaText = t === 'object'
|
|
241
|
+
? `Object { ${previewKeys(keysForObject, cfg.maxPreview)} }`
|
|
242
|
+
: `Array(${value.length})`;
|
|
243
|
+
const { summary } = buildSummaryRow(keyLabel, metaText, t, cfg);
|
|
244
|
+
details.appendChild(summary);
|
|
245
|
+
|
|
246
|
+
// Children
|
|
247
|
+
if (t === 'object') {
|
|
248
|
+
const keys = keysForObject || Object.keys(value);
|
|
249
|
+
for (const k of keys) {
|
|
250
|
+
const childVal = value[k];
|
|
251
|
+
const childPath = path.concat(k);
|
|
252
|
+
const childType = typeOf(childVal);
|
|
253
|
+
|
|
254
|
+
// Handle lazy properties (functions that start with _lazy)
|
|
255
|
+
if (k.startsWith('_lazy') && typeof childVal === 'function') {
|
|
256
|
+
const lazyDetails = document.createElement('details');
|
|
257
|
+
lazyDetails.open = shouldDetailsOpen(childPath, cfg);
|
|
258
|
+
lazyDetails.setAttribute('data-path', pathToString(childPath));
|
|
259
|
+
lazyDetails.setAttribute('data-key', k);
|
|
260
|
+
const friendlyName = formatLazyKey(k);
|
|
261
|
+
const { summary: lazySummary, metaEl } = buildSummaryRow(friendlyName, 'Lazy value', 'lazy', cfg);
|
|
262
|
+
lazyDetails.appendChild(lazySummary);
|
|
263
|
+
|
|
264
|
+
let loaded = false;
|
|
265
|
+
const loadLazyValue = () => {
|
|
266
|
+
if (loaded) return;
|
|
267
|
+
loaded = true;
|
|
268
|
+
if (metaEl) metaEl.textContent = 'Loading…';
|
|
269
|
+
try {
|
|
270
|
+
const result = childVal();
|
|
271
|
+
lazyDetails.setAttribute('data-loaded', 'true');
|
|
272
|
+
const actualNode = buildNode(state, result, childPath, cfg);
|
|
273
|
+
if (actualNode.tagName === 'DETAILS') actualNode.open = true;
|
|
274
|
+
lazyDetails.replaceWith(actualNode);
|
|
275
|
+
} catch (err) {
|
|
276
|
+
const msg = err?.message || String(err);
|
|
277
|
+
if (metaEl) {
|
|
278
|
+
metaEl.textContent = `Failed to load: ${msg}`;
|
|
279
|
+
metaEl.style.color = '#ef4444';
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
lazyDetails.addEventListener('toggle', () => {
|
|
285
|
+
if (lazyDetails.open) loadLazyValue();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
details.appendChild(lazyDetails);
|
|
289
|
+
} else if (childType === 'object' || childType === 'array') {
|
|
290
|
+
details.appendChild(buildNode(state, childVal, childPath, cfg));
|
|
291
|
+
} else {
|
|
292
|
+
details.appendChild(renderKV(state, k, childVal, childPath, cfg));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
} else if (t === 'array') {
|
|
296
|
+
for (let i = 0; i < value.length; i++) {
|
|
297
|
+
const childVal = value[i];
|
|
298
|
+
const childPath = path.concat(i);
|
|
299
|
+
const childType = typeOf(childVal);
|
|
300
|
+
|
|
301
|
+
if (childType === 'object' || childType === 'array') {
|
|
302
|
+
details.appendChild(buildNode(state, childVal, childPath, cfg));
|
|
303
|
+
} else {
|
|
304
|
+
details.appendChild(renderKV(state, `[${i}]`, childVal, childPath, cfg));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return details;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function previewKeys(keys, maxLen) {
|
|
313
|
+
const joined = keys.join(', ');
|
|
314
|
+
return joined.length <= maxLen ? joined : joined.slice(0, maxLen - 1) + '…';
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function pathToString(path) {
|
|
318
|
+
if (!path.length) return '(root)';
|
|
319
|
+
return path.map(p => typeof p === 'number' ? `[${p}]` : `.${String(p)}`).join('').replace(/^\./, '');
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Render a single key-value row with read-only, copyable inputs.
|
|
323
|
+
function renderKV(state, key, value, path, cfg) {
|
|
324
|
+
const t = typeOf(value);
|
|
325
|
+
const row = document.createElement('div');
|
|
326
|
+
row.className = 'kv';
|
|
327
|
+
row.setAttribute('data-path', pathToString(path));
|
|
328
|
+
row.setAttribute('data-key', String(key));
|
|
329
|
+
|
|
330
|
+
// Spacer to align with chevron column
|
|
331
|
+
row.appendChild(document.createElement('div')); // empty 14px col
|
|
332
|
+
|
|
333
|
+
const keyEl = document.createElement('div');
|
|
334
|
+
keyEl.className = 'key';
|
|
335
|
+
keyEl.textContent = String(key);
|
|
336
|
+
row.appendChild(keyEl);
|
|
337
|
+
|
|
338
|
+
// Value editor
|
|
339
|
+
const valueEl = document.createElement('div');
|
|
340
|
+
const editor = makeEditorForType(value, t);
|
|
341
|
+
valueEl.appendChild(editor);
|
|
342
|
+
row.appendChild(valueEl);
|
|
343
|
+
|
|
344
|
+
const typeBadge = document.createElement('div');
|
|
345
|
+
typeBadge.className = 'type-badge';
|
|
346
|
+
typeBadge.textContent = t;
|
|
347
|
+
if (!cfg.showTypes) typeBadge.style.display = 'none';
|
|
348
|
+
row.appendChild(typeBadge);
|
|
349
|
+
|
|
350
|
+
return row;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function makeEditorForType(value, t) {
|
|
354
|
+
switch (t) {
|
|
355
|
+
case 'string': {
|
|
356
|
+
const inp = document.createElement('input');
|
|
357
|
+
inp.className = 'value-input';
|
|
358
|
+
inp.type = 'text';
|
|
359
|
+
inp.value = value ?? '';
|
|
360
|
+
return lockInputForCopy(inp);
|
|
361
|
+
}
|
|
362
|
+
case 'number': {
|
|
363
|
+
const inp = document.createElement('input');
|
|
364
|
+
inp.className = 'value-input';
|
|
365
|
+
inp.type = 'number';
|
|
366
|
+
inp.value = Number.isFinite(value) ? String(value) : '';
|
|
367
|
+
inp.step = 'any';
|
|
368
|
+
return lockInputForCopy(inp);
|
|
369
|
+
}
|
|
370
|
+
case 'bigint': {
|
|
371
|
+
const inp = document.createElement('input');
|
|
372
|
+
inp.className = 'value-input';
|
|
373
|
+
inp.type = 'text';
|
|
374
|
+
inp.value = value?.toString() ?? '';
|
|
375
|
+
return lockInputForCopy(inp);
|
|
376
|
+
}
|
|
377
|
+
case 'boolean': {
|
|
378
|
+
const inp = document.createElement('input');
|
|
379
|
+
inp.className = 'value-input';
|
|
380
|
+
inp.type = 'text';
|
|
381
|
+
inp.value = value ? 'true' : 'false';
|
|
382
|
+
return lockInputForCopy(inp);
|
|
383
|
+
}
|
|
384
|
+
case 'date': {
|
|
385
|
+
const inp = document.createElement('input');
|
|
386
|
+
inp.className = 'value-date';
|
|
387
|
+
inp.type = 'date';
|
|
388
|
+
const d = (value instanceof Date) ? value : new Date(value);
|
|
389
|
+
const yyyy = d.getFullYear();
|
|
390
|
+
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
|
391
|
+
const dd = String(d.getDate()).padStart(2, '0');
|
|
392
|
+
inp.value = isNaN(d.getTime()) ? '' : `${yyyy}-${mm}-${dd}`;
|
|
393
|
+
return lockInputForCopy(inp);
|
|
394
|
+
}
|
|
395
|
+
case 'undefined':
|
|
396
|
+
case 'null':
|
|
397
|
+
case 'symbol':
|
|
398
|
+
case 'function': {
|
|
399
|
+
const span = document.createElement('span');
|
|
400
|
+
span.className = 'value-input readonly';
|
|
401
|
+
span.textContent = showPreview(value, 80);
|
|
402
|
+
span.title = 'read-only';
|
|
403
|
+
return span;
|
|
404
|
+
}
|
|
405
|
+
case 'object':
|
|
406
|
+
case 'array': {
|
|
407
|
+
// Fallback JSON editor for leaf that ended up here (should be rare)
|
|
408
|
+
const inp = document.createElement('input');
|
|
409
|
+
inp.className = 'value-input';
|
|
410
|
+
try {
|
|
411
|
+
inp.value = JSON.stringify(value);
|
|
412
|
+
} catch {
|
|
413
|
+
inp.value = String(value);
|
|
414
|
+
}
|
|
415
|
+
return lockInputForCopy(inp);
|
|
416
|
+
}
|
|
417
|
+
default: {
|
|
418
|
+
const inp = document.createElement('input');
|
|
419
|
+
inp.className = 'value-input';
|
|
420
|
+
inp.type = 'text';
|
|
421
|
+
inp.value = String(value ?? '');
|
|
422
|
+
return lockInputForCopy(inp);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function showPreview(v, max = 40) {
|
|
428
|
+
let s;
|
|
429
|
+
try {
|
|
430
|
+
if (typeof v === 'function') s = `[Function ${v.name || 'anonymous'}]`;
|
|
431
|
+
else if (typeof v === 'symbol') s = v.toString();
|
|
432
|
+
else if (v instanceof Date) s = v.toISOString();
|
|
433
|
+
else {
|
|
434
|
+
const j = JSON.stringify(v, replacerForJSON());
|
|
435
|
+
s = (j === undefined ? String(v) : j);
|
|
436
|
+
}
|
|
437
|
+
} catch {
|
|
438
|
+
s = String(v);
|
|
439
|
+
}
|
|
440
|
+
s = String(s ?? '');
|
|
441
|
+
return s.length <= max ? s : s.slice(0, max - 1) + '…';
|
|
442
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { HistoryCollectionWidget } from '../history/HistoryCollectionWidget.js';
|
|
2
|
+
|
|
3
|
+
export class AnnotationCollectionWidget extends HistoryCollectionWidget {
|
|
4
|
+
constructor({
|
|
5
|
+
history = null,
|
|
6
|
+
pmimode = null,
|
|
7
|
+
onEntryChange = null,
|
|
8
|
+
onCollectionChange = null,
|
|
9
|
+
onEntryToggle = null,
|
|
10
|
+
} = {}) {
|
|
11
|
+
const externalChange = typeof onEntryChange === 'function' ? onEntryChange : null;
|
|
12
|
+
const externalCollection = typeof onCollectionChange === 'function' ? onCollectionChange : null;
|
|
13
|
+
const externalToggle = typeof onEntryToggle === 'function' ? onEntryToggle : null;
|
|
14
|
+
|
|
15
|
+
super({
|
|
16
|
+
history,
|
|
17
|
+
viewer: pmimode?.viewer || null,
|
|
18
|
+
entryToggle: history ? {
|
|
19
|
+
getTitle: () => 'Show or hide this annotation',
|
|
20
|
+
isEnabled: ({ entry }) => entry?.enabled !== false,
|
|
21
|
+
setEnabled: ({ entry }, value) => {
|
|
22
|
+
const entryId = entry?.inputParams?.id || entry?.id;
|
|
23
|
+
if (!entryId || typeof history.setAnnotationEnabled !== 'function') return;
|
|
24
|
+
history.setAnnotationEnabled(entryId, value);
|
|
25
|
+
},
|
|
26
|
+
} : null,
|
|
27
|
+
decorateEntryHeader: (context) => {
|
|
28
|
+
const item = context?.elements?.item;
|
|
29
|
+
if (!item) return;
|
|
30
|
+
const disabled = context?.entry?.enabled === false;
|
|
31
|
+
item.classList.toggle('annotation-disabled', disabled);
|
|
32
|
+
},
|
|
33
|
+
onEntryChange: (payload) => {
|
|
34
|
+
this.#applyEntryChange(payload);
|
|
35
|
+
if (externalChange) {
|
|
36
|
+
try { externalChange(payload); } catch (_) { /* ignore */ }
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
onCollectionChange: (payload) => {
|
|
40
|
+
this.#handleCollectionChange(payload);
|
|
41
|
+
if (externalCollection) {
|
|
42
|
+
try { externalCollection(payload); } catch (_) { /* ignore */ }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
onEntryToggle: externalToggle ? ((entry, isOpen) => {
|
|
46
|
+
try { externalToggle(entry, isOpen); } catch (_) { /* ignore */ }
|
|
47
|
+
}) : null,
|
|
48
|
+
autoSyncOpenState: true,
|
|
49
|
+
createEntry: async (typeStr) => {
|
|
50
|
+
if (!typeStr || !history || typeof history.createAnnotation !== 'function') return null;
|
|
51
|
+
return history.createAnnotation(typeStr);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
this.pmimode = pmimode || null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#applyEntryChange({ entry, details }) {
|
|
59
|
+
if (!entry) return;
|
|
60
|
+
try {
|
|
61
|
+
const registry = this.history?.registry;
|
|
62
|
+
let handler = null;
|
|
63
|
+
if (registry && typeof registry.resolve === 'function') {
|
|
64
|
+
handler = registry.resolve(entry.type || entry.entityType);
|
|
65
|
+
}
|
|
66
|
+
if (!handler && entry.constructor) handler = entry.constructor;
|
|
67
|
+
if (handler && typeof handler.applyParams === 'function') {
|
|
68
|
+
const helpers = details?.helpers;
|
|
69
|
+
handler.applyParams(this.pmimode, entry.inputParams, entry.inputParams, helpers);
|
|
70
|
+
}
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.warn('[AnnotationCollectionWidget] applyParams failed:', error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#handleCollectionChange({ reason, entry }) {
|
|
77
|
+
if (!entry || !this.pmimode) return;
|
|
78
|
+
try {
|
|
79
|
+
switch (reason) {
|
|
80
|
+
case 'add':
|
|
81
|
+
this.pmimode.normalizeAnnotation(entry.inputParams);
|
|
82
|
+
this.pmimode.markAnnotationsDirty();
|
|
83
|
+
break;
|
|
84
|
+
case 'remove':
|
|
85
|
+
this.pmimode.handleAnnotationRemoval(entry);
|
|
86
|
+
this.pmimode.markAnnotationsDirty();
|
|
87
|
+
break;
|
|
88
|
+
case 'reorder':
|
|
89
|
+
this.pmimode.markAnnotationsDirty();
|
|
90
|
+
this.pmimode.applyViewTransformsSequential?.();
|
|
91
|
+
break;
|
|
92
|
+
case 'update':
|
|
93
|
+
this.pmimode.markAnnotationsDirty();
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.warn('[AnnotationCollectionWidget] collection change handler failed:', error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_augmentHelperContext(baseHelpers, context) {
|
|
104
|
+
const extra = super._augmentHelperContext(baseHelpers, context) || {};
|
|
105
|
+
const pmimode = this.pmimode || null;
|
|
106
|
+
if (!pmimode) return extra;
|
|
107
|
+
const merged = {
|
|
108
|
+
pmimode,
|
|
109
|
+
viewer: pmimode.viewer || baseHelpers.viewer || null,
|
|
110
|
+
refreshAnnotationsUI() {
|
|
111
|
+
try { pmimode.refreshAnnotationsUI?.(); } catch (_) { /* ignore */ }
|
|
112
|
+
},
|
|
113
|
+
markAnnotationsDirty() {
|
|
114
|
+
try { pmimode.markAnnotationsDirty?.(); } catch (_) { /* ignore */ }
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
return { ...extra, ...merged };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|