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,457 @@
|
|
|
1
|
+
import { SelectionFilter } from './SelectionFilter.js';
|
|
2
|
+
import { HistoryCollectionWidget } from './history/HistoryCollectionWidget.js';
|
|
3
|
+
|
|
4
|
+
const FALLBACK_INTERVAL_MS = 200;
|
|
5
|
+
|
|
6
|
+
export class HistoryWidget extends HistoryCollectionWidget {
|
|
7
|
+
constructor(viewer) {
|
|
8
|
+
const partHistory = viewer?.partHistory || null;
|
|
9
|
+
super({ history: partHistory, viewer });
|
|
10
|
+
this.viewer = viewer || null;
|
|
11
|
+
this.partHistory = partHistory || null;
|
|
12
|
+
|
|
13
|
+
// Override configurable hooks from the base widget after super() so they can access `this`.
|
|
14
|
+
this._autoSyncOpenState = true;
|
|
15
|
+
this._determineExpanded = (entry) => this.#shouldExpandEntry(entry);
|
|
16
|
+
this._formOptionsProvider = (context) => this.#buildFormOptions(context);
|
|
17
|
+
this._decorateEntryHeader = (context) => this.#decorateEntryHeader(context);
|
|
18
|
+
this._buildEntryControls = null; // stick with defaults; override move/delete behaviours directly.
|
|
19
|
+
this._onEntryToggle = (entry, isOpen) => this.#handleEntryToggle(entry, isOpen);
|
|
20
|
+
this._onFormReady = (payload) => this.#handleFormReady(payload);
|
|
21
|
+
this._createEntryFunc = (type) => this.#createFeatureEntry(type);
|
|
22
|
+
this.onEntryChange = (payload) => this.#handleEntryChange(payload);
|
|
23
|
+
|
|
24
|
+
this._metaEls = new Map();
|
|
25
|
+
this._itemEls = new Map();
|
|
26
|
+
this._paramSignatures = new Map();
|
|
27
|
+
this._idsSignature = this.#computeIdsSignature();
|
|
28
|
+
this._rafHandle = null;
|
|
29
|
+
this._rafIsTimeout = false;
|
|
30
|
+
this._runPromise = null;
|
|
31
|
+
|
|
32
|
+
this.uiElement.classList.add('history-widget');
|
|
33
|
+
this.render();
|
|
34
|
+
this.#startAutoSyncLoop();
|
|
35
|
+
this.#patchRunHistory();
|
|
36
|
+
this.partHistory?.queueHistorySnapshot?.({ debounceMs: 0, reason: 'init' });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
dispose() {
|
|
40
|
+
this.#stopAutoSyncLoop();
|
|
41
|
+
super.dispose();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
if (!this._metaEls) this._metaEls = new Map();
|
|
46
|
+
if (!this._itemEls) this._itemEls = new Map();
|
|
47
|
+
if (!this._paramSignatures) this._paramSignatures = new Map();
|
|
48
|
+
this._metaEls.clear();
|
|
49
|
+
this._itemEls.clear();
|
|
50
|
+
super.render();
|
|
51
|
+
this._syncHeaderState();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async _moveEntry(id, delta) {
|
|
55
|
+
const entryInfo = this.#findEntryInfo(id);
|
|
56
|
+
if (!entryInfo) return;
|
|
57
|
+
super._moveEntry(id, delta);
|
|
58
|
+
this._idsSignature = this.#computeIdsSignature();
|
|
59
|
+
const feature = entryInfo.entry;
|
|
60
|
+
if (feature) {
|
|
61
|
+
feature.lastRunInputParams = null;
|
|
62
|
+
const featureId = this.#entryId(feature);
|
|
63
|
+
if (featureId) this.#setCurrentHistoryStep(featureId);
|
|
64
|
+
}
|
|
65
|
+
await this.#safeRunHistory();
|
|
66
|
+
this.partHistory?.queueHistorySnapshot?.({ debounceMs: 0, reason: 'move' });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_deleteEntry(id) {
|
|
70
|
+
const entryInfo = this.#findEntryInfo(id);
|
|
71
|
+
super._deleteEntry(id);
|
|
72
|
+
const featureId = entryInfo ? this.#entryId(entryInfo.entry) : null;
|
|
73
|
+
if (featureId && this.partHistory && this.partHistory.currentHistoryStepId === featureId) {
|
|
74
|
+
this.partHistory.currentHistoryStepId = null;
|
|
75
|
+
}
|
|
76
|
+
this._idsSignature = this.#computeIdsSignature();
|
|
77
|
+
const runPromise = this.#safeRunHistory();
|
|
78
|
+
if (runPromise && typeof runPromise.then === 'function') {
|
|
79
|
+
runPromise.then(() => {
|
|
80
|
+
this.partHistory?.queueHistorySnapshot?.({ debounceMs: 0, reason: 'delete' });
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
this.partHistory?.queueHistorySnapshot?.({ debounceMs: 0, reason: 'delete' });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_refreshAddMenu() {
|
|
88
|
+
if (!this._addMenu || !this._addBtn) return;
|
|
89
|
+
const registry = this._getFeatureRegistry();
|
|
90
|
+
const features = Array.isArray(registry?.features) ? registry.features : [];
|
|
91
|
+
this._addMenu.textContent = '';
|
|
92
|
+
if (!features.length) {
|
|
93
|
+
this._addBtn.disabled = true;
|
|
94
|
+
const empty = document.createElement('div');
|
|
95
|
+
empty.className = 'hc-menu-empty';
|
|
96
|
+
empty.textContent = 'No features registered';
|
|
97
|
+
this._addMenu.appendChild(empty);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const items = [];
|
|
101
|
+
for (const FC of features) {
|
|
102
|
+
if (!FC) continue;
|
|
103
|
+
const names = this._extractDisplayNames(
|
|
104
|
+
FC,
|
|
105
|
+
FC?.shortName || FC?.name || 'Feature',
|
|
106
|
+
FC?.longName || FC?.name || 'Feature',
|
|
107
|
+
);
|
|
108
|
+
const label = names.longName || names.shortName || 'Feature';
|
|
109
|
+
const value = FC?.shortName || FC?.type || FC?.name || names.shortName || label;
|
|
110
|
+
const item = this._composeMenuItem(value, label, FC);
|
|
111
|
+
if (item) items.push(item);
|
|
112
|
+
}
|
|
113
|
+
if (!items.length) {
|
|
114
|
+
this._addBtn.disabled = true;
|
|
115
|
+
const empty = document.createElement('div');
|
|
116
|
+
empty.className = 'hc-menu-empty';
|
|
117
|
+
empty.textContent = 'No features registered';
|
|
118
|
+
this._addMenu.appendChild(empty);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this._addBtn.disabled = false;
|
|
122
|
+
for (const { type, text } of items) {
|
|
123
|
+
const btn = document.createElement('button');
|
|
124
|
+
btn.type = 'button';
|
|
125
|
+
btn.className = 'hc-menu-item';
|
|
126
|
+
btn.textContent = text;
|
|
127
|
+
btn.dataset.type = type;
|
|
128
|
+
btn.addEventListener('click', async (ev) => {
|
|
129
|
+
ev.stopPropagation();
|
|
130
|
+
const targetType = ev?.currentTarget?.dataset?.type || type;
|
|
131
|
+
try {
|
|
132
|
+
await this._handleAddEntry(targetType);
|
|
133
|
+
} finally {
|
|
134
|
+
this._toggleAddMenu(false);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
this._addMenu.appendChild(btn);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_resolveSchema(entry) {
|
|
142
|
+
const FeatureClass = this._resolveFeatureClass(entry?.type);
|
|
143
|
+
return FeatureClass?.inputParamsSchema || null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
#findEntryInfo(id) {
|
|
147
|
+
if (id == null) return null;
|
|
148
|
+
const entries = this._getEntries();
|
|
149
|
+
const stringId = String(id);
|
|
150
|
+
for (let i = 0; i < entries.length; i++) {
|
|
151
|
+
const entry = entries[i];
|
|
152
|
+
const entryId = this._extractEntryId(entry, i);
|
|
153
|
+
if (entryId === stringId) {
|
|
154
|
+
return { entry, index: i };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
#startAutoSyncLoop() {
|
|
161
|
+
const useRaf = typeof requestAnimationFrame === 'function';
|
|
162
|
+
this._rafIsTimeout = !useRaf;
|
|
163
|
+
const tick = () => {
|
|
164
|
+
const sig = this.#computeIdsSignature();
|
|
165
|
+
if (sig !== this._idsSignature) {
|
|
166
|
+
this._idsSignature = sig;
|
|
167
|
+
this.render();
|
|
168
|
+
} else {
|
|
169
|
+
this.#refreshOpenForms();
|
|
170
|
+
this._syncHeaderState();
|
|
171
|
+
this.#ensureCurrentExpanded();
|
|
172
|
+
}
|
|
173
|
+
if (useRaf) this._rafHandle = requestAnimationFrame(tick);
|
|
174
|
+
else this._rafHandle = setTimeout(tick, FALLBACK_INTERVAL_MS);
|
|
175
|
+
};
|
|
176
|
+
tick();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#stopAutoSyncLoop() {
|
|
180
|
+
if (this._rafHandle == null) return;
|
|
181
|
+
if (this._rafIsTimeout) clearTimeout(this._rafHandle);
|
|
182
|
+
else if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(this._rafHandle);
|
|
183
|
+
this._rafHandle = null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
#patchRunHistory() {
|
|
187
|
+
const ph = this.partHistory;
|
|
188
|
+
if (!ph || typeof ph.runHistory !== 'function' || ph.__historyWidgetPatched) return;
|
|
189
|
+
const original = ph.runHistory.bind(ph);
|
|
190
|
+
ph.runHistory = async (...args) => {
|
|
191
|
+
const res = await original(...args);
|
|
192
|
+
this.#afterPartHistoryMutated();
|
|
193
|
+
return res;
|
|
194
|
+
};
|
|
195
|
+
ph.__historyWidgetPatched = true;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#afterPartHistoryMutated() {
|
|
199
|
+
this._idsSignature = this.#computeIdsSignature();
|
|
200
|
+
this._syncHeaderState();
|
|
201
|
+
this.#refreshOpenForms();
|
|
202
|
+
try { this.viewer?._refreshAssemblyConstraintsPanelVisibility?.(); } catch { /* ignore */ }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async #createFeatureEntry(typeStr) {
|
|
206
|
+
const ph = this.partHistory;
|
|
207
|
+
if (!ph || typeof ph.newFeature !== 'function') return null;
|
|
208
|
+
try {
|
|
209
|
+
const feature = await ph.newFeature(typeStr);
|
|
210
|
+
const newId = this.#entryId(feature);
|
|
211
|
+
if (newId) this.#setCurrentHistoryStep(newId);
|
|
212
|
+
await this.#safeRunHistory();
|
|
213
|
+
this.partHistory?.queueHistorySnapshot?.({ debounceMs: 0, reason: 'add' });
|
|
214
|
+
this._idsSignature = this.#computeIdsSignature();
|
|
215
|
+
return feature;
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.warn('[HistoryWidget] Failed to create feature:', error);
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#shouldExpandEntry(entry) {
|
|
223
|
+
const target = this.partHistory?.currentHistoryStepId;
|
|
224
|
+
if (!target) return false;
|
|
225
|
+
const id = this.#entryId(entry);
|
|
226
|
+
if (id == null || String(id) !== String(target)) return false;
|
|
227
|
+
const runtimeOpen = entry?.runtimeAttributes?.__open;
|
|
228
|
+
const paramOpen = entry?.inputParams?.__open;
|
|
229
|
+
if (runtimeOpen === false || paramOpen === false) return false;
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#handleEntryToggle(entry, isOpen) {
|
|
234
|
+
if (!this.partHistory) return;
|
|
235
|
+
const id = this.#entryId(entry);
|
|
236
|
+
if (!id) return;
|
|
237
|
+
if (isOpen) {
|
|
238
|
+
this.#setCurrentHistoryStep(id);
|
|
239
|
+
} else {
|
|
240
|
+
if (String(this.partHistory.currentHistoryStepId) === String(id)) {
|
|
241
|
+
this.partHistory.currentHistoryStepId = null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
this.#safeRunHistory();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
#handleEntryChange({ entry }) {
|
|
248
|
+
const id = this.#entryId(entry);
|
|
249
|
+
if (id) this.#setCurrentHistoryStep(id);
|
|
250
|
+
const runPromise = this.#safeRunHistory();
|
|
251
|
+
if (runPromise && typeof runPromise.then === 'function') {
|
|
252
|
+
runPromise.then(() => {
|
|
253
|
+
this.partHistory?.queueHistorySnapshot?.({ reason: 'edit' });
|
|
254
|
+
});
|
|
255
|
+
} else {
|
|
256
|
+
this.partHistory?.queueHistorySnapshot?.({ reason: 'edit' });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
#handleFormReady({ id, entry }) {
|
|
261
|
+
if (!id || !entry) return;
|
|
262
|
+
this._paramSignatures.set(String(id), this.#computeParamsSig(entry.inputParams));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
#buildFormOptions(context = {}) {
|
|
266
|
+
const entry = context?.entry || null;
|
|
267
|
+
const featureId = this.#entryId(entry);
|
|
268
|
+
return {
|
|
269
|
+
onChange: () => {
|
|
270
|
+
if (featureId) this.#setCurrentHistoryStep(featureId);
|
|
271
|
+
},
|
|
272
|
+
onAction: (_id, actionKey) => this.#handleFormAction(featureId, actionKey),
|
|
273
|
+
onReferenceChipRemove: (name) => this.#handleReferenceChipRemove(name),
|
|
274
|
+
scene: this.viewer?.scene || null,
|
|
275
|
+
viewer: this.viewer || null,
|
|
276
|
+
partHistory: this.partHistory || null,
|
|
277
|
+
featureRef: entry || null,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
#handleFormAction(featureID, actionKey) {
|
|
282
|
+
if (!actionKey || !this.viewer) return;
|
|
283
|
+
try {
|
|
284
|
+
if (actionKey === 'editSketch' && typeof this.viewer.startSketchMode === 'function') {
|
|
285
|
+
this.viewer.startSketchMode(featureID);
|
|
286
|
+
} else if (actionKey === 'editSpline' && typeof this.viewer.startSplineMode === 'function') {
|
|
287
|
+
this.viewer.startSplineMode(featureID);
|
|
288
|
+
}
|
|
289
|
+
} catch {
|
|
290
|
+
/* ignore */
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
#handleReferenceChipRemove(name) {
|
|
295
|
+
if (!name) return;
|
|
296
|
+
try {
|
|
297
|
+
const scene = this.viewer?.scene || null;
|
|
298
|
+
if (scene) SelectionFilter.deselectItem(scene, name);
|
|
299
|
+
} catch {
|
|
300
|
+
/* ignore */
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
#decorateEntryHeader(context = {}) {
|
|
305
|
+
const id = context?.id != null ? String(context.id) : null;
|
|
306
|
+
const entry = context?.entry || null;
|
|
307
|
+
const elements = context?.elements || {};
|
|
308
|
+
this._applyDisplayInfo(entry, context?.index || 0, id, {
|
|
309
|
+
titleEl: elements.titleEl,
|
|
310
|
+
metaEl: elements.metaEl,
|
|
311
|
+
item: elements.item,
|
|
312
|
+
});
|
|
313
|
+
if (id && elements.metaEl) this._metaEls.set(id, elements.metaEl);
|
|
314
|
+
if (id && elements.item) this._itemEls.set(id, elements.item);
|
|
315
|
+
this.#decorateMissingFeaturePanel(entry, context);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
#decorateMissingFeaturePanel(entry, context = {}) {
|
|
319
|
+
if (!context.isOpen) return;
|
|
320
|
+
const FeatureClass = this._resolveFeatureClass(entry?.type);
|
|
321
|
+
if (FeatureClass) return;
|
|
322
|
+
const body = context.elements?.bodyEl;
|
|
323
|
+
if (!body) return;
|
|
324
|
+
body.textContent = '';
|
|
325
|
+
const wrap = document.createElement('div');
|
|
326
|
+
wrap.className = 'missing-feature-panel';
|
|
327
|
+
const msg = document.createElement('div');
|
|
328
|
+
msg.className = 'missing-msg';
|
|
329
|
+
msg.textContent = `Feature type "${entry?.type || ''}" is not available. Remove it or install a plugin that provides it.`;
|
|
330
|
+
wrap.appendChild(msg);
|
|
331
|
+
const removeBtn = document.createElement('button');
|
|
332
|
+
removeBtn.type = 'button';
|
|
333
|
+
removeBtn.className = 'hc-btn danger';
|
|
334
|
+
removeBtn.textContent = 'Remove from history';
|
|
335
|
+
removeBtn.addEventListener('click', (ev) => {
|
|
336
|
+
ev.stopPropagation();
|
|
337
|
+
this._deleteEntry(context.id);
|
|
338
|
+
});
|
|
339
|
+
wrap.appendChild(removeBtn);
|
|
340
|
+
body.appendChild(wrap);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
_syncHeaderState() {
|
|
344
|
+
const entries = this._getEntries();
|
|
345
|
+
for (let i = 0; i < entries.length; i++) {
|
|
346
|
+
const entry = entries[i];
|
|
347
|
+
const id = this._extractEntryId(entry, i);
|
|
348
|
+
if (id == null) continue;
|
|
349
|
+
const titleEl = this._titleEls.get(String(id));
|
|
350
|
+
const metaEl = this._metaEls.get(String(id));
|
|
351
|
+
const item = this._itemEls.get(String(id));
|
|
352
|
+
if (!titleEl && !metaEl && !item) continue;
|
|
353
|
+
this._applyDisplayInfo(entry, i, String(id), {
|
|
354
|
+
titleEl,
|
|
355
|
+
metaEl,
|
|
356
|
+
item,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
#refreshOpenForms() {
|
|
362
|
+
const entries = this._getEntries();
|
|
363
|
+
for (let i = 0; i < entries.length; i++) {
|
|
364
|
+
const entry = entries[i];
|
|
365
|
+
const id = this._extractEntryId(entry, i);
|
|
366
|
+
if (id == null) continue;
|
|
367
|
+
const form = this.getFormForEntry(id);
|
|
368
|
+
if (!form) continue;
|
|
369
|
+
const sig = this.#computeParamsSig(entry?.inputParams);
|
|
370
|
+
if (this._paramSignatures.get(id) === sig) continue;
|
|
371
|
+
this._paramSignatures.set(id, sig);
|
|
372
|
+
try { form.refreshFromParams?.(); } catch { /* ignore */ }
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
#ensureCurrentExpanded() {
|
|
377
|
+
const ph = this.partHistory;
|
|
378
|
+
if (!ph) return;
|
|
379
|
+
const target = ph.currentHistoryStepId;
|
|
380
|
+
if (!target) return;
|
|
381
|
+
if (this._expandedId && String(this._expandedId) === String(target)) return;
|
|
382
|
+
const entries = this._getEntries();
|
|
383
|
+
const exists = entries.some((entry, idx) => this._extractEntryId(entry, idx) === String(target));
|
|
384
|
+
if (!exists) return;
|
|
385
|
+
this._expandedId = String(target);
|
|
386
|
+
this.render();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
#computeIdsSignature() {
|
|
390
|
+
const features = this._getEntries();
|
|
391
|
+
return features
|
|
392
|
+
.map((entry, idx) => this._extractEntryId(entry, idx))
|
|
393
|
+
.filter((id) => id != null)
|
|
394
|
+
.join('|');
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
#computeParamsSig(params) {
|
|
398
|
+
if (!params || typeof params !== 'object') return '';
|
|
399
|
+
const keys = Object.keys(params).filter((k) => k !== 'featureID' && k !== 'id').sort();
|
|
400
|
+
const parts = [];
|
|
401
|
+
for (const key of keys) {
|
|
402
|
+
const value = params[key];
|
|
403
|
+
if (value == null) parts.push(`${key}:null`);
|
|
404
|
+
else if (typeof value === 'object' || typeof value === 'function') parts.push(`${key}:[obj]`);
|
|
405
|
+
else parts.push(`${key}:${String(value)}`);
|
|
406
|
+
}
|
|
407
|
+
return parts.join('|');
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
#entryId(entry) {
|
|
411
|
+
if (!entry) return null;
|
|
412
|
+
const params = entry.inputParams || {};
|
|
413
|
+
if (params.id != null) return String(params.id);
|
|
414
|
+
if (params.featureID != null) return String(params.featureID);
|
|
415
|
+
if (params.id != null) return String(params.id);
|
|
416
|
+
if (entry.id != null) return String(entry.id);
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
#setCurrentHistoryStep(id) {
|
|
421
|
+
if (!this.partHistory) return;
|
|
422
|
+
this.partHistory.currentHistoryStepId = id != null ? String(id) : null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
#safeRunHistory() {
|
|
426
|
+
if (!this.partHistory || typeof this.partHistory.runHistory !== 'function') {
|
|
427
|
+
return Promise.resolve();
|
|
428
|
+
}
|
|
429
|
+
const previous = this._runPromise || Promise.resolve();
|
|
430
|
+
const next = previous.then(async () => {
|
|
431
|
+
try {
|
|
432
|
+
await this.partHistory.runHistory();
|
|
433
|
+
} catch (error) {
|
|
434
|
+
console.warn('[HistoryWidget] runHistory failed:', error);
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
this._runPromise = next.catch((error) => {
|
|
438
|
+
console.warn('[HistoryWidget] runHistory sequence failed:', error);
|
|
439
|
+
});
|
|
440
|
+
return this._runPromise;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
_getFeatureRegistry() {
|
|
444
|
+
return this.partHistory?.featureRegistry || null;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
_resolveFeatureClass(type) {
|
|
448
|
+
if (!type) return null;
|
|
449
|
+
const registry = this._getFeatureRegistry();
|
|
450
|
+
if (!registry) return null;
|
|
451
|
+
try {
|
|
452
|
+
return registry.getSafe?.(type) || registry.get?.(type) || null;
|
|
453
|
+
} catch {
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// MainToolbar.js - top toolbar that manages layout and button registration.
|
|
2
|
+
// Button logic is implemented externally and registered via addCustomButton()/viewer.addToolbarButton.
|
|
3
|
+
|
|
4
|
+
export class MainToolbar {
|
|
5
|
+
constructor(viewer) {
|
|
6
|
+
this.viewer = viewer;
|
|
7
|
+
// Guard against duplicate toolbars if constructed twice (e.g., hot reloads)
|
|
8
|
+
try {
|
|
9
|
+
const existing = document.getElementById('main-toolbar');
|
|
10
|
+
if (existing && existing.parentNode) existing.parentNode.removeChild(existing);
|
|
11
|
+
} catch { /* ignore */ }
|
|
12
|
+
this.root = document.createElement('div');
|
|
13
|
+
this.root.id = 'main-toolbar';
|
|
14
|
+
this._ensureStyles();
|
|
15
|
+
this._buildUI();
|
|
16
|
+
this._positionWithSidebar();
|
|
17
|
+
|
|
18
|
+
// Keep position in sync with sidebar and window resizes
|
|
19
|
+
window.addEventListener('resize', () => this._positionWithSidebar());
|
|
20
|
+
try {
|
|
21
|
+
if (window.ResizeObserver && this.viewer?.sidebar) {
|
|
22
|
+
const ro = new ResizeObserver(() => this._positionWithSidebar());
|
|
23
|
+
ro.observe(this.viewer.sidebar);
|
|
24
|
+
this._ro = ro;
|
|
25
|
+
}
|
|
26
|
+
} catch { /* ignore */ }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_ensureStyles() {
|
|
30
|
+
if (document.getElementById('main-toolbar-styles')) return;
|
|
31
|
+
const style = document.createElement('style');
|
|
32
|
+
style.id = 'main-toolbar-styles';
|
|
33
|
+
style.textContent = `
|
|
34
|
+
#main-toolbar {
|
|
35
|
+
position: fixed;
|
|
36
|
+
top: 0; left: 0; right: 0;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-wrap: wrap;
|
|
39
|
+
align-items: center;
|
|
40
|
+
justify-content: flex-start;
|
|
41
|
+
gap: 6px;
|
|
42
|
+
padding: 6px;
|
|
43
|
+
background: rgba(20,24,30,.85);
|
|
44
|
+
border: 1px solid #262b36;
|
|
45
|
+
border-radius: 8px;
|
|
46
|
+
z-index: 10;
|
|
47
|
+
pointer-events: auto;
|
|
48
|
+
user-select: none;
|
|
49
|
+
}
|
|
50
|
+
.mtb-left, .mtb-right {
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-wrap: wrap;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: 6px;
|
|
55
|
+
min-width: 0;
|
|
56
|
+
}
|
|
57
|
+
.mtb-left { flex: 1 1 auto; }
|
|
58
|
+
.mtb-right { margin-left: auto; justify-content: flex-end; }
|
|
59
|
+
.mtb-spacer { flex: 1; }
|
|
60
|
+
|
|
61
|
+
.mtb-btn {
|
|
62
|
+
background: transparent;
|
|
63
|
+
color: #ddd;
|
|
64
|
+
border: 1px solid #364053;
|
|
65
|
+
padding: 4px 8px;
|
|
66
|
+
border-radius: 6px;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
font-size: 13px;
|
|
69
|
+
line-height: 18px;
|
|
70
|
+
user-select: none;
|
|
71
|
+
}
|
|
72
|
+
.mtb-btn.mtb-icon {
|
|
73
|
+
min-width: 36px;
|
|
74
|
+
font-size: 16px;
|
|
75
|
+
}
|
|
76
|
+
.mtb-btn.is-active {
|
|
77
|
+
background: linear-gradient(180deg, rgba(110,168,254,.25), rgba(110,168,254,.15));
|
|
78
|
+
border-color: #6ea8fe;
|
|
79
|
+
color: #e9f0ff;
|
|
80
|
+
box-shadow: 0 0 0 1px rgba(110,168,254,.2) inset;
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
document.head.appendChild(style);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_buildUI() {
|
|
87
|
+
const left = document.createElement('div');
|
|
88
|
+
left.className = 'mtb-left';
|
|
89
|
+
this._left = left;
|
|
90
|
+
|
|
91
|
+
// Buttons are provided by external modules via addCustomButton()/viewer.addToolbarButton
|
|
92
|
+
|
|
93
|
+
const right = document.createElement('div');
|
|
94
|
+
right.className = 'mtb-right';
|
|
95
|
+
|
|
96
|
+
this.root.appendChild(left);
|
|
97
|
+
this.root.appendChild(right);
|
|
98
|
+
document.body.appendChild(this.root);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_btn(label, title, onClick) {
|
|
102
|
+
const b = document.createElement('button');
|
|
103
|
+
b.className = 'mtb-btn';
|
|
104
|
+
b.textContent = label;
|
|
105
|
+
b.title = title || label;
|
|
106
|
+
b.addEventListener('click', (e) => { e.stopPropagation(); try { onClick && onClick(); } catch {} });
|
|
107
|
+
return b;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Public: allow plugins to add custom buttons to the left cluster
|
|
111
|
+
addCustomButton({ label, title, onClick }) {
|
|
112
|
+
try {
|
|
113
|
+
const btn = this._btn(String(label ?? '🔧'), String(title || ''), onClick);
|
|
114
|
+
this._left?.appendChild(btn);
|
|
115
|
+
return btn;
|
|
116
|
+
} catch { return null; }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
_positionWithSidebar() {
|
|
120
|
+
try {
|
|
121
|
+
const sb = this.viewer?.sidebar;
|
|
122
|
+
const shouldOffset = (typeof this.viewer?._getSidebarShouldShow === 'function')
|
|
123
|
+
? this.viewer._getSidebarShouldShow()
|
|
124
|
+
: true;
|
|
125
|
+
const w = shouldOffset
|
|
126
|
+
? Math.ceil(sb?.getBoundingClientRect?.().width || sb?.offsetWidth || 0)
|
|
127
|
+
: 0;
|
|
128
|
+
this.root.style.left = `${w}px`;
|
|
129
|
+
} catch { this.root.style.left = '0px'; }
|
|
130
|
+
}
|
|
131
|
+
}
|