@linkiez/dxf-renew 5.3.1
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/.eslintignore +17 -0
- package/.eslintrc.json +61 -0
- package/.gitattributes +4 -0
- package/.github/instructions/project-en_US.instructions.md +352 -0
- package/.github/workflows/release.yml +110 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +6 -0
- package/.releaserc.json +76 -0
- package/.travis.yml +6 -0
- package/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -0
- package/CHANGELOG.md +134 -0
- package/CONTRIBUTING.md +271 -0
- package/LICENSE +21 -0
- package/PLAN.md +517 -0
- package/README.md +306 -0
- package/build.mjs +66 -0
- package/commitlint.config.js +25 -0
- package/dist/dxf.js +7234 -0
- package/docs/CODE_PATTERNS.md +182 -0
- package/docs/DIMENSION_SUMMARY.md +248 -0
- package/docs/DIMENSION_SUMMARY.pt-BR.md +248 -0
- package/docs/IMPLEMENTED-2D-ENTITIES.md +54 -0
- package/docs/IMPLEMENTED-2D-ENTITIES.pt-BR.md +54 -0
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +241 -0
- package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.pt-BR.md +169 -0
- package/docs/autocad_2012_pdf_dxf-reference_enu.md +8272 -0
- package/examples/dxf.html +36 -0
- package/examples/example.es5.js +30 -0
- package/examples/example.es6.js +30 -0
- package/examples/text-dimension-viewer.html +133 -0
- package/lib/Helper.cjs +89 -0
- package/lib/Helper.cjs.map +7 -0
- package/lib/Helper.js +59 -0
- package/lib/Helper.js.map +7 -0
- package/lib/applyTransforms.cjs +59 -0
- package/lib/applyTransforms.cjs.map +7 -0
- package/lib/applyTransforms.js +39 -0
- package/lib/applyTransforms.js.map +7 -0
- package/lib/cli.cjs +53 -0
- package/lib/cli.cjs.map +7 -0
- package/lib/cli.js +29 -0
- package/lib/cli.js.map +7 -0
- package/lib/config.cjs +30 -0
- package/lib/config.cjs.map +7 -0
- package/lib/config.js +10 -0
- package/lib/config.js.map +7 -0
- package/lib/constants.cjs +39 -0
- package/lib/constants.cjs.map +7 -0
- package/lib/constants.js +15 -0
- package/lib/constants.js.map +7 -0
- package/lib/denormalise.cjs +148 -0
- package/lib/denormalise.cjs.map +7 -0
- package/lib/denormalise.js +118 -0
- package/lib/denormalise.js.map +7 -0
- package/lib/dimensionToSVG.cjs +307 -0
- package/lib/dimensionToSVG.cjs.map +7 -0
- package/lib/dimensionToSVG.js +273 -0
- package/lib/dimensionToSVG.js.map +7 -0
- package/lib/entityToPolyline.cjs +248 -0
- package/lib/entityToPolyline.cjs.map +7 -0
- package/lib/entityToPolyline.js +213 -0
- package/lib/entityToPolyline.js.map +7 -0
- package/lib/getRGBForEntity.cjs +53 -0
- package/lib/getRGBForEntity.cjs.map +7 -0
- package/lib/getRGBForEntity.js +23 -0
- package/lib/getRGBForEntity.js.map +7 -0
- package/lib/groupEntitiesByLayer.cjs +34 -0
- package/lib/groupEntitiesByLayer.cjs.map +7 -0
- package/lib/groupEntitiesByLayer.js +14 -0
- package/lib/groupEntitiesByLayer.js.map +7 -0
- package/lib/handlers/blocks.cjs +93 -0
- package/lib/handlers/blocks.cjs.map +7 -0
- package/lib/handlers/blocks.js +63 -0
- package/lib/handlers/blocks.js.map +7 -0
- package/lib/handlers/entities.cjs +118 -0
- package/lib/handlers/entities.cjs.map +7 -0
- package/lib/handlers/entities.js +88 -0
- package/lib/handlers/entities.js.map +7 -0
- package/lib/handlers/entity/arc.cjs +82 -0
- package/lib/handlers/entity/arc.cjs.map +7 -0
- package/lib/handlers/entity/arc.js +47 -0
- package/lib/handlers/entity/arc.js.map +7 -0
- package/lib/handlers/entity/attdef.cjs +318 -0
- package/lib/handlers/entity/attdef.cjs.map +7 -0
- package/lib/handlers/entity/attdef.js +282 -0
- package/lib/handlers/entity/attdef.js.map +7 -0
- package/lib/handlers/entity/attrib.cjs +52 -0
- package/lib/handlers/entity/attrib.cjs.map +7 -0
- package/lib/handlers/entity/attrib.js +27 -0
- package/lib/handlers/entity/attrib.js.map +7 -0
- package/lib/handlers/entity/circle.cjs +73 -0
- package/lib/handlers/entity/circle.cjs.map +7 -0
- package/lib/handlers/entity/circle.js +38 -0
- package/lib/handlers/entity/circle.js.map +7 -0
- package/lib/handlers/entity/common.cjs +83 -0
- package/lib/handlers/entity/common.cjs.map +7 -0
- package/lib/handlers/entity/common.js +63 -0
- package/lib/handlers/entity/common.js.map +7 -0
- package/lib/handlers/entity/dimension.cjs +203 -0
- package/lib/handlers/entity/dimension.cjs.map +7 -0
- package/lib/handlers/entity/dimension.js +168 -0
- package/lib/handlers/entity/dimension.js.map +7 -0
- package/lib/handlers/entity/ellipse.cjs +88 -0
- package/lib/handlers/entity/ellipse.cjs.map +7 -0
- package/lib/handlers/entity/ellipse.js +53 -0
- package/lib/handlers/entity/ellipse.js.map +7 -0
- package/lib/handlers/entity/hatch.cjs +470 -0
- package/lib/handlers/entity/hatch.cjs.map +7 -0
- package/lib/handlers/entity/hatch.js +435 -0
- package/lib/handlers/entity/hatch.js.map +7 -0
- package/lib/handlers/entity/insert.cjs +106 -0
- package/lib/handlers/entity/insert.cjs.map +7 -0
- package/lib/handlers/entity/insert.js +71 -0
- package/lib/handlers/entity/insert.js.map +7 -0
- package/lib/handlers/entity/line.cjs +84 -0
- package/lib/handlers/entity/line.cjs.map +7 -0
- package/lib/handlers/entity/line.js +49 -0
- package/lib/handlers/entity/line.js.map +7 -0
- package/lib/handlers/entity/lwpolyline.cjs +82 -0
- package/lib/handlers/entity/lwpolyline.cjs.map +7 -0
- package/lib/handlers/entity/lwpolyline.js +47 -0
- package/lib/handlers/entity/lwpolyline.js.map +7 -0
- package/lib/handlers/entity/mtext.cjs +121 -0
- package/lib/handlers/entity/mtext.cjs.map +7 -0
- package/lib/handlers/entity/mtext.js +85 -0
- package/lib/handlers/entity/mtext.js.map +7 -0
- package/lib/handlers/entity/ole2Frame.cjs +98 -0
- package/lib/handlers/entity/ole2Frame.cjs.map +7 -0
- package/lib/handlers/entity/ole2Frame.js +63 -0
- package/lib/handlers/entity/ole2Frame.js.map +7 -0
- package/lib/handlers/entity/point.cjs +73 -0
- package/lib/handlers/entity/point.cjs.map +7 -0
- package/lib/handlers/entity/point.js +38 -0
- package/lib/handlers/entity/point.js.map +7 -0
- package/lib/handlers/entity/polyline.cjs +70 -0
- package/lib/handlers/entity/polyline.cjs.map +7 -0
- package/lib/handlers/entity/polyline.js +35 -0
- package/lib/handlers/entity/polyline.js.map +7 -0
- package/lib/handlers/entity/solid.cjs +101 -0
- package/lib/handlers/entity/solid.cjs.map +7 -0
- package/lib/handlers/entity/solid.js +66 -0
- package/lib/handlers/entity/solid.js.map +7 -0
- package/lib/handlers/entity/spline.cjs +109 -0
- package/lib/handlers/entity/spline.cjs.map +7 -0
- package/lib/handlers/entity/spline.js +74 -0
- package/lib/handlers/entity/spline.js.map +7 -0
- package/lib/handlers/entity/text.cjs +85 -0
- package/lib/handlers/entity/text.cjs.map +7 -0
- package/lib/handlers/entity/text.js +49 -0
- package/lib/handlers/entity/text.js.map +7 -0
- package/lib/handlers/entity/threeDFace.cjs +98 -0
- package/lib/handlers/entity/threeDFace.cjs.map +7 -0
- package/lib/handlers/entity/threeDFace.js +63 -0
- package/lib/handlers/entity/threeDFace.js.map +7 -0
- package/lib/handlers/entity/vertex.cjs +78 -0
- package/lib/handlers/entity/vertex.cjs.map +7 -0
- package/lib/handlers/entity/vertex.js +53 -0
- package/lib/handlers/entity/vertex.js.map +7 -0
- package/lib/handlers/entity/viewport.cjs +153 -0
- package/lib/handlers/entity/viewport.cjs.map +7 -0
- package/lib/handlers/entity/viewport.js +118 -0
- package/lib/handlers/entity/viewport.js.map +7 -0
- package/lib/handlers/header.cjs +92 -0
- package/lib/handlers/header.cjs.map +7 -0
- package/lib/handlers/header.js +72 -0
- package/lib/handlers/header.js.map +7 -0
- package/lib/handlers/objects.cjs +170 -0
- package/lib/handlers/objects.cjs.map +7 -0
- package/lib/handlers/objects.js +150 -0
- package/lib/handlers/objects.js.map +7 -0
- package/lib/handlers/tables.cjs +587 -0
- package/lib/handlers/tables.cjs.map +7 -0
- package/lib/handlers/tables.js +557 -0
- package/lib/handlers/tables.js.map +7 -0
- package/lib/index.cjs +60 -0
- package/lib/index.cjs.map +7 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +7 -0
- package/lib/parseString.cjs +118 -0
- package/lib/parseString.cjs.map +7 -0
- package/lib/parseString.js +88 -0
- package/lib/parseString.js.map +7 -0
- package/lib/toPolylines.cjs +69 -0
- package/lib/toPolylines.cjs.map +7 -0
- package/lib/toPolylines.js +39 -0
- package/lib/toPolylines.js.map +7 -0
- package/lib/toSVG.cjs +395 -0
- package/lib/toSVG.cjs.map +7 -0
- package/lib/toSVG.js +361 -0
- package/lib/toSVG.js.map +7 -0
- package/lib/types/arc-entity.cjs +17 -0
- package/lib/types/arc-entity.cjs.map +7 -0
- package/lib/types/arc-entity.js +1 -0
- package/lib/types/arc-entity.js.map +7 -0
- package/lib/types/base-entity.cjs +17 -0
- package/lib/types/base-entity.cjs.map +7 -0
- package/lib/types/base-entity.js +1 -0
- package/lib/types/base-entity.js.map +7 -0
- package/lib/types/circle-entity.cjs +17 -0
- package/lib/types/circle-entity.cjs.map +7 -0
- package/lib/types/circle-entity.js +1 -0
- package/lib/types/circle-entity.js.map +7 -0
- package/lib/types/common.cjs +17 -0
- package/lib/types/common.cjs.map +7 -0
- package/lib/types/common.js +1 -0
- package/lib/types/common.js.map +7 -0
- package/lib/types/dimension-entity.cjs +17 -0
- package/lib/types/dimension-entity.cjs.map +7 -0
- package/lib/types/dimension-entity.js +1 -0
- package/lib/types/dimension-entity.js.map +7 -0
- package/lib/types/dxf.cjs +17 -0
- package/lib/types/dxf.cjs.map +7 -0
- package/lib/types/dxf.js +1 -0
- package/lib/types/dxf.js.map +7 -0
- package/lib/types/ellipse-entity.cjs +17 -0
- package/lib/types/ellipse-entity.cjs.map +7 -0
- package/lib/types/ellipse-entity.js +1 -0
- package/lib/types/ellipse-entity.js.map +7 -0
- package/lib/types/entity.cjs +17 -0
- package/lib/types/entity.cjs.map +7 -0
- package/lib/types/entity.js +1 -0
- package/lib/types/entity.js.map +7 -0
- package/lib/types/handler-internal.cjs +17 -0
- package/lib/types/handler-internal.cjs.map +7 -0
- package/lib/types/handler-internal.js +1 -0
- package/lib/types/handler-internal.js.map +7 -0
- package/lib/types/handler.cjs +17 -0
- package/lib/types/handler.cjs.map +7 -0
- package/lib/types/handler.js +1 -0
- package/lib/types/handler.js.map +7 -0
- package/lib/types/hatch-entity.cjs +17 -0
- package/lib/types/hatch-entity.cjs.map +7 -0
- package/lib/types/hatch-entity.js +1 -0
- package/lib/types/hatch-entity.js.map +7 -0
- package/lib/types/helper.cjs +17 -0
- package/lib/types/helper.cjs.map +7 -0
- package/lib/types/helper.js +1 -0
- package/lib/types/helper.js.map +7 -0
- package/lib/types/index.cjs +77 -0
- package/lib/types/index.cjs.map +7 -0
- package/lib/types/index.js +29 -0
- package/lib/types/index.js.map +7 -0
- package/lib/types/insert-entity.cjs +17 -0
- package/lib/types/insert-entity.cjs.map +7 -0
- package/lib/types/insert-entity.js +1 -0
- package/lib/types/insert-entity.js.map +7 -0
- package/lib/types/layer-groups.cjs +17 -0
- package/lib/types/layer-groups.cjs.map +7 -0
- package/lib/types/layer-groups.js +1 -0
- package/lib/types/layer-groups.js.map +7 -0
- package/lib/types/line-entity.cjs +17 -0
- package/lib/types/line-entity.cjs.map +7 -0
- package/lib/types/line-entity.js +1 -0
- package/lib/types/line-entity.js.map +7 -0
- package/lib/types/mtext-entity.cjs +17 -0
- package/lib/types/mtext-entity.cjs.map +7 -0
- package/lib/types/mtext-entity.js +1 -0
- package/lib/types/mtext-entity.js.map +7 -0
- package/lib/types/ole2frame-entity.cjs +17 -0
- package/lib/types/ole2frame-entity.cjs.map +7 -0
- package/lib/types/ole2frame-entity.js +1 -0
- package/lib/types/ole2frame-entity.js.map +7 -0
- package/lib/types/options.cjs +17 -0
- package/lib/types/options.cjs.map +7 -0
- package/lib/types/options.js +1 -0
- package/lib/types/options.js.map +7 -0
- package/lib/types/point-entity.cjs +17 -0
- package/lib/types/point-entity.cjs.map +7 -0
- package/lib/types/point-entity.js +1 -0
- package/lib/types/point-entity.js.map +7 -0
- package/lib/types/polyline-entity.cjs +17 -0
- package/lib/types/polyline-entity.cjs.map +7 -0
- package/lib/types/polyline-entity.js +1 -0
- package/lib/types/polyline-entity.js.map +7 -0
- package/lib/types/polylines.cjs +17 -0
- package/lib/types/polylines.cjs.map +7 -0
- package/lib/types/polylines.js +1 -0
- package/lib/types/polylines.js.map +7 -0
- package/lib/types/solid-entity.cjs +17 -0
- package/lib/types/solid-entity.cjs.map +7 -0
- package/lib/types/solid-entity.js +1 -0
- package/lib/types/solid-entity.js.map +7 -0
- package/lib/types/spline-entity.cjs +17 -0
- package/lib/types/spline-entity.cjs.map +7 -0
- package/lib/types/spline-entity.js +1 -0
- package/lib/types/spline-entity.js.map +7 -0
- package/lib/types/svg.cjs +17 -0
- package/lib/types/svg.cjs.map +7 -0
- package/lib/types/svg.js +1 -0
- package/lib/types/svg.js.map +7 -0
- package/lib/types/tables.cjs +17 -0
- package/lib/types/tables.cjs.map +7 -0
- package/lib/types/tables.js +1 -0
- package/lib/types/tables.js.map +7 -0
- package/lib/types/text-entity.cjs +17 -0
- package/lib/types/text-entity.cjs.map +7 -0
- package/lib/types/text-entity.js +1 -0
- package/lib/types/text-entity.js.map +7 -0
- package/lib/types/util-types.cjs +17 -0
- package/lib/types/util-types.cjs.map +7 -0
- package/lib/types/util-types.js +1 -0
- package/lib/types/util-types.js.map +7 -0
- package/lib/types/vecks.d.cjs +2 -0
- package/lib/types/vecks.d.cjs.map +7 -0
- package/lib/types/vecks.d.js +1 -0
- package/lib/types/vecks.d.js.map +7 -0
- package/lib/types/viewport-entity.cjs +17 -0
- package/lib/types/viewport-entity.cjs.map +7 -0
- package/lib/types/viewport-entity.js +1 -0
- package/lib/types/viewport-entity.js.map +7 -0
- package/lib/types.cjs +23 -0
- package/lib/types.cjs.map +7 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +7 -0
- package/lib/util/bSpline.cjs +95 -0
- package/lib/util/bSpline.cjs.map +7 -0
- package/lib/util/bSpline.js +65 -0
- package/lib/util/bSpline.js.map +7 -0
- package/lib/util/colors.cjs +283 -0
- package/lib/util/colors.cjs.map +7 -0
- package/lib/util/colors.js +263 -0
- package/lib/util/colors.js.map +7 -0
- package/lib/util/createArcForLWPolyline.cjs +84 -0
- package/lib/util/createArcForLWPolyline.cjs.map +7 -0
- package/lib/util/createArcForLWPolyline.js +64 -0
- package/lib/util/createArcForLWPolyline.js.map +7 -0
- package/lib/util/dxfColorToRGB.cjs +115 -0
- package/lib/util/dxfColorToRGB.cjs.map +7 -0
- package/lib/util/dxfColorToRGB.js +90 -0
- package/lib/util/dxfColorToRGB.js.map +7 -0
- package/lib/util/insertKnot.cjs +77 -0
- package/lib/util/insertKnot.cjs.map +7 -0
- package/lib/util/insertKnot.js +57 -0
- package/lib/util/insertKnot.js.map +7 -0
- package/lib/util/logger.cjs +53 -0
- package/lib/util/logger.cjs.map +7 -0
- package/lib/util/logger.js +23 -0
- package/lib/util/logger.js.map +7 -0
- package/lib/util/rgbToColorAttribute.cjs +32 -0
- package/lib/util/rgbToColorAttribute.cjs.map +7 -0
- package/lib/util/rgbToColorAttribute.js +12 -0
- package/lib/util/rgbToColorAttribute.js.map +7 -0
- package/lib/util/rotate.cjs +30 -0
- package/lib/util/rotate.cjs.map +7 -0
- package/lib/util/rotate.js +10 -0
- package/lib/util/rotate.js.map +7 -0
- package/lib/util/round10.cjs +38 -0
- package/lib/util/round10.cjs.map +7 -0
- package/lib/util/round10.js +18 -0
- package/lib/util/round10.js.map +7 -0
- package/lib/util/toPiecewiseBezier.cjs +90 -0
- package/lib/util/toPiecewiseBezier.cjs.map +7 -0
- package/lib/util/toPiecewiseBezier.js +54 -0
- package/lib/util/toPiecewiseBezier.js.map +7 -0
- package/lib/util/transformBoundingBoxAndElement.cjs +80 -0
- package/lib/util/transformBoundingBoxAndElement.cjs.map +7 -0
- package/lib/util/transformBoundingBoxAndElement.js +60 -0
- package/lib/util/transformBoundingBoxAndElement.js.map +7 -0
- package/package.json +127 -0
- package/src/Helper.ts +71 -0
- package/src/applyTransforms.ts +54 -0
- package/src/cli.ts +41 -0
- package/src/config.ts +10 -0
- package/src/constants.ts +14 -0
- package/src/denormalise.ts +153 -0
- package/src/dimensionToSVG.ts +427 -0
- package/src/entityToPolyline.ts +338 -0
- package/src/getRGBForEntity.ts +28 -0
- package/src/groupEntitiesByLayer.ts +14 -0
- package/src/handlers/blocks.ts +65 -0
- package/src/handlers/entities.ts +111 -0
- package/src/handlers/entity/arc.ts +61 -0
- package/src/handlers/entity/attdef.ts +284 -0
- package/src/handlers/entity/attrib.ts +29 -0
- package/src/handlers/entity/circle.ts +47 -0
- package/src/handlers/entity/common.ts +79 -0
- package/src/handlers/entity/dimension.ts +217 -0
- package/src/handlers/entity/ellipse.ts +55 -0
- package/src/handlers/entity/hatch.ts +471 -0
- package/src/handlers/entity/insert.ts +73 -0
- package/src/handlers/entity/line.ts +56 -0
- package/src/handlers/entity/lwpolyline.ts +54 -0
- package/src/handlers/entity/mtext.ts +150 -0
- package/src/handlers/entity/ole2Frame.ts +64 -0
- package/src/handlers/entity/point.ts +47 -0
- package/src/handlers/entity/polyline.ts +49 -0
- package/src/handlers/entity/solid.ts +73 -0
- package/src/handlers/entity/spline.ts +103 -0
- package/src/handlers/entity/text.ts +83 -0
- package/src/handlers/entity/threeDFace.ts +69 -0
- package/src/handlers/entity/vertex.ts +55 -0
- package/src/handlers/entity/viewport.ts +119 -0
- package/src/handlers/header.ts +73 -0
- package/src/handlers/objects.ts +152 -0
- package/src/handlers/tables.ts +581 -0
- package/src/index.ts +19 -0
- package/src/parseString.ts +97 -0
- package/src/toPolylines.ts +47 -0
- package/src/toSVG.ts +518 -0
- package/src/types/README.md +91 -0
- package/src/types/arc-entity.ts +10 -0
- package/src/types/base-entity.ts +25 -0
- package/src/types/circle-entity.ts +8 -0
- package/src/types/common.ts +37 -0
- package/src/types/dimension-entity.ts +23 -0
- package/src/types/dxf.ts +64 -0
- package/src/types/ellipse-entity.ts +13 -0
- package/src/types/entity.ts +32 -0
- package/src/types/handler-internal.ts +51 -0
- package/src/types/handler.ts +10 -0
- package/src/types/hatch-entity.ts +127 -0
- package/src/types/helper.ts +12 -0
- package/src/types/index.ts +53 -0
- package/src/types/insert-entity.ts +19 -0
- package/src/types/layer-groups.ts +8 -0
- package/src/types/line-entity.ts +10 -0
- package/src/types/mtext-entity.ts +35 -0
- package/src/types/ole2frame-entity.ts +35 -0
- package/src/types/options.ts +17 -0
- package/src/types/point-entity.ts +7 -0
- package/src/types/polyline-entity.ts +20 -0
- package/src/types/polylines.ts +22 -0
- package/src/types/solid-entity.ts +9 -0
- package/src/types/spline-entity.ts +12 -0
- package/src/types/svg.ts +31 -0
- package/src/types/tables.ts +414 -0
- package/src/types/text-entity.ts +23 -0
- package/src/types/util-types.ts +27 -0
- package/src/types/vecks.d.ts +29 -0
- package/src/types/viewport-entity.ts +81 -0
- package/src/types.ts +5 -0
- package/src/util/bSpline.ts +97 -0
- package/src/util/colors.ts +266 -0
- package/src/util/createArcForLWPolyline.ts +93 -0
- package/src/util/diagram.png +0 -0
- package/src/util/dxfColorToRGB.ts +106 -0
- package/src/util/insertKnot.ts +69 -0
- package/src/util/logger.ts +23 -0
- package/src/util/rgbToColorAttribute.ts +14 -0
- package/src/util/rotate.ts +14 -0
- package/src/util/round10.ts +24 -0
- package/src/util/toPiecewiseBezier.ts +70 -0
- package/src/util/transformBoundingBoxAndElement.ts +74 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>DXF Browser Example</title>
|
|
6
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.min.js"></script>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<input type="file" id="file" />
|
|
10
|
+
<div>Number of entities:<span id="numberOfEntities">-</span></div>
|
|
11
|
+
<div id="svg"></div>
|
|
12
|
+
<script>
|
|
13
|
+
var numberOfEntities = document.getElementById('numberOfEntities')
|
|
14
|
+
var svgContainer = document.getElementById('svg')
|
|
15
|
+
var fileInput = document.getElementById('file')
|
|
16
|
+
window.requirejs(['../dist/dxf'], function (dxf) {
|
|
17
|
+
dxf.config.verbose = true
|
|
18
|
+
fileInput.addEventListener('change', function (event) {
|
|
19
|
+
var file = event.target.files[0]
|
|
20
|
+
var reader = new FileReader()
|
|
21
|
+
numberOfEntities.innerHTML = 'reading...'
|
|
22
|
+
reader.onload = function (e) {
|
|
23
|
+
if (e.target.readyState === 2) {
|
|
24
|
+
var dxfContents = e.target.result
|
|
25
|
+
var helper = new dxf.Helper(dxfContents)
|
|
26
|
+
numberOfEntities.innerHTML = helper.denormalised.length
|
|
27
|
+
const svg = helper.toSVG()
|
|
28
|
+
svgContainer.innerHTML = svg
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
reader.readAsBinaryString(file)
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
35
|
+
</body>
|
|
36
|
+
</html>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const join = require('path').join
|
|
3
|
+
|
|
4
|
+
const Helper = require('..').Helper
|
|
5
|
+
|
|
6
|
+
const helper = new Helper(
|
|
7
|
+
fs.readFileSync('./test/resources/Ceco.NET-Architecture-Tm-53.dxf', 'utf-8'),
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// The parsed entities
|
|
11
|
+
const { blocks, entities } = helper.parsed
|
|
12
|
+
console.log(`parsed: ${blocks.length} blocks, ${entities.length} entities.\n`)
|
|
13
|
+
|
|
14
|
+
// Denormalised blocks inserted with transforms applied
|
|
15
|
+
console.log(`denormalised: ${helper.denormalised.length} entities.\n`)
|
|
16
|
+
|
|
17
|
+
// Group entities by layer. Returns an object with layer names as
|
|
18
|
+
// keys to arrays of entities.
|
|
19
|
+
const groups = helper.groups
|
|
20
|
+
console.log('grouped entities')
|
|
21
|
+
console.log('----------------')
|
|
22
|
+
Object.keys(groups).forEach((layer) => {
|
|
23
|
+
console.log(`${layer}: ${groups[layer].length}`)
|
|
24
|
+
})
|
|
25
|
+
console.log('\n')
|
|
26
|
+
|
|
27
|
+
// Write the SVG
|
|
28
|
+
const svg = helper.toSVG()
|
|
29
|
+
fs.writeFileSync(join(__dirname, '/example.es5.svg'), svg, 'utf-8')
|
|
30
|
+
console.log('SVG written')
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
|
|
4
|
+
import { Helper } from '../src'
|
|
5
|
+
|
|
6
|
+
const helper = new Helper(
|
|
7
|
+
fs.readFileSync('./test/resources/Ceco.NET-Architecture-Tm-53.dxf', 'utf-8'),
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
// The parsed entities
|
|
11
|
+
const { blocks, entities } = helper.parsed
|
|
12
|
+
console.log(`parsed: ${blocks.length} blocks, ${entities.length} entities.\n`)
|
|
13
|
+
|
|
14
|
+
// Denormalised blocks inserted with transforms applied
|
|
15
|
+
console.log(`denormalised: ${helper.denormalised.length} entities.\n`)
|
|
16
|
+
|
|
17
|
+
// Group entities by layer. Returns an object with layer names as
|
|
18
|
+
// keys to arrays of entities.
|
|
19
|
+
const groups = helper.groups
|
|
20
|
+
console.log('grouped entities')
|
|
21
|
+
console.log('----------------')
|
|
22
|
+
Object.keys(groups).forEach((layer) => {
|
|
23
|
+
console.log(`${layer}: ${groups[layer].length}`)
|
|
24
|
+
})
|
|
25
|
+
console.log('\n')
|
|
26
|
+
|
|
27
|
+
// Write the SVG
|
|
28
|
+
const svg = helper.toSVG()
|
|
29
|
+
fs.writeFileSync(join(__dirname, '/example.es6.svg'), svg, 'utf-8')
|
|
30
|
+
console.log('SVG written')
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>DXF Text and Dimension Example</title>
|
|
6
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.min.js"></script>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: Arial, sans-serif;
|
|
10
|
+
margin: 20px;
|
|
11
|
+
}
|
|
12
|
+
.container {
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 20px;
|
|
15
|
+
}
|
|
16
|
+
.controls {
|
|
17
|
+
flex: 0 0 300px;
|
|
18
|
+
}
|
|
19
|
+
.viewer {
|
|
20
|
+
flex: 1;
|
|
21
|
+
border: 1px solid #ccc;
|
|
22
|
+
min-height: 600px;
|
|
23
|
+
background: #f5f5f5;
|
|
24
|
+
}
|
|
25
|
+
button {
|
|
26
|
+
margin: 5px 0;
|
|
27
|
+
padding: 10px;
|
|
28
|
+
width: 100%;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
#svg {
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
}
|
|
35
|
+
.info {
|
|
36
|
+
margin-top: 10px;
|
|
37
|
+
padding: 10px;
|
|
38
|
+
background: #e8e8e8;
|
|
39
|
+
border-radius: 4px;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<h1>DXF Text, MTEXT and Dimension Viewer</h1>
|
|
45
|
+
<div class="container">
|
|
46
|
+
<div class="controls">
|
|
47
|
+
<h3>Controls</h3>
|
|
48
|
+
<input type="file" id="file" accept=".dxf" />
|
|
49
|
+
<div class="info">
|
|
50
|
+
<div>Number of entities: <span id="numberOfEntities">-</span></div>
|
|
51
|
+
<div>TEXT entities: <span id="textCount">-</span></div>
|
|
52
|
+
<div>MTEXT entities: <span id="mtextCount">-</span></div>
|
|
53
|
+
<div>DIMENSION entities: <span id="dimensionCount">-</span></div>
|
|
54
|
+
</div>
|
|
55
|
+
<h4>Test Files</h4>
|
|
56
|
+
<button onclick="loadTestFile('texts.dxf')">Load texts.dxf</button>
|
|
57
|
+
<button onclick="loadTestFile('dimensions.dxf')">Load dimensions.dxf</button>
|
|
58
|
+
<button onclick="loadTestFile('dimension-vertical.dxf')">Load dimension-vertical.dxf</button>
|
|
59
|
+
<button onclick="loadTestFile('entities.dxf')">Load entities.dxf (all)</button>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="viewer" id="svg"></div>
|
|
62
|
+
</div>
|
|
63
|
+
<script>
|
|
64
|
+
var numberOfEntities = document.getElementById('numberOfEntities')
|
|
65
|
+
var textCount = document.getElementById('textCount')
|
|
66
|
+
var mtextCount = document.getElementById('mtextCount')
|
|
67
|
+
var dimensionCount = document.getElementById('dimensionCount')
|
|
68
|
+
var svgContainer = document.getElementById('svg')
|
|
69
|
+
var fileInput = document.getElementById('file')
|
|
70
|
+
|
|
71
|
+
function countEntitiesByType(entities) {
|
|
72
|
+
const counts = {
|
|
73
|
+
TEXT: 0,
|
|
74
|
+
MTEXT: 0,
|
|
75
|
+
DIMENSION: 0
|
|
76
|
+
}
|
|
77
|
+
entities.forEach(entity => {
|
|
78
|
+
if (counts.hasOwnProperty(entity.type)) {
|
|
79
|
+
counts[entity.type]++
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
return counts
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function renderDXF(dxfContents) {
|
|
86
|
+
window.requirejs(['../dist/dxf'], function (dxf) {
|
|
87
|
+
dxf.config.verbose = true
|
|
88
|
+
try {
|
|
89
|
+
numberOfEntities.innerHTML = 'processing...'
|
|
90
|
+
const helper = new dxf.Helper(dxfContents)
|
|
91
|
+
numberOfEntities.innerHTML = helper.denormalised.length
|
|
92
|
+
|
|
93
|
+
const counts = countEntitiesByType(helper.denormalised)
|
|
94
|
+
textCount.innerHTML = counts.TEXT
|
|
95
|
+
mtextCount.innerHTML = counts.MTEXT
|
|
96
|
+
dimensionCount.innerHTML = counts.DIMENSION
|
|
97
|
+
|
|
98
|
+
const svg = helper.toSVG()
|
|
99
|
+
svgContainer.innerHTML = svg
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('Error rendering DXF:', error)
|
|
102
|
+
svgContainer.innerHTML = '<p style="color: red;">Error: ' + error.message + '</p>'
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
fileInput.addEventListener('change', function (event) {
|
|
108
|
+
var file = event.target.files[0]
|
|
109
|
+
var reader = new FileReader()
|
|
110
|
+
numberOfEntities.innerHTML = 'reading...'
|
|
111
|
+
reader.onload = function (e) {
|
|
112
|
+
if (e.target.readyState === 2) {
|
|
113
|
+
renderDXF(e.target.result)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
reader.readAsBinaryString(file)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
window.loadTestFile = function(filename) {
|
|
120
|
+
numberOfEntities.innerHTML = 'loading...'
|
|
121
|
+
fetch('../test/resources/' + filename)
|
|
122
|
+
.then(response => response.text())
|
|
123
|
+
.then(dxfContents => {
|
|
124
|
+
renderDXF(dxfContents)
|
|
125
|
+
})
|
|
126
|
+
.catch(error => {
|
|
127
|
+
console.error('Error loading file:', error)
|
|
128
|
+
svgContainer.innerHTML = '<p style="color: red;">Error loading file: ' + error.message + '</p>'
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
</script>
|
|
132
|
+
</body>
|
|
133
|
+
</html>
|
package/lib/Helper.cjs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Helper_exports = {};
|
|
30
|
+
__export(Helper_exports, {
|
|
31
|
+
default: () => Helper
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Helper_exports);
|
|
34
|
+
var import_denormalise = __toESM(require("./denormalise"), 1);
|
|
35
|
+
var import_groupEntitiesByLayer = __toESM(require("./groupEntitiesByLayer"), 1);
|
|
36
|
+
var import_parseString = __toESM(require("./parseString"), 1);
|
|
37
|
+
var import_toPolylines = __toESM(require("./toPolylines"), 1);
|
|
38
|
+
var import_toSVG = __toESM(require("./toSVG"), 1);
|
|
39
|
+
var import_logger = __toESM(require("./util/logger"), 1);
|
|
40
|
+
class Helper {
|
|
41
|
+
constructor(contents) {
|
|
42
|
+
if (typeof contents !== "string") {
|
|
43
|
+
throw new TypeError("Helper constructor expects a DXF string");
|
|
44
|
+
}
|
|
45
|
+
this._contents = contents;
|
|
46
|
+
this._parsed = null;
|
|
47
|
+
this._denormalised = null;
|
|
48
|
+
this._groups = null;
|
|
49
|
+
}
|
|
50
|
+
parse() {
|
|
51
|
+
this._parsed = (0, import_parseString.default)(this._contents);
|
|
52
|
+
import_logger.default.info("parsed:", this.parsed);
|
|
53
|
+
return this._parsed;
|
|
54
|
+
}
|
|
55
|
+
get parsed() {
|
|
56
|
+
if (this._parsed === null) {
|
|
57
|
+
this.parse();
|
|
58
|
+
}
|
|
59
|
+
return this._parsed;
|
|
60
|
+
}
|
|
61
|
+
denormalise() {
|
|
62
|
+
this._denormalised = (0, import_denormalise.default)(this.parsed);
|
|
63
|
+
import_logger.default.info("denormalised:", this._denormalised);
|
|
64
|
+
return this._denormalised;
|
|
65
|
+
}
|
|
66
|
+
get denormalised() {
|
|
67
|
+
if (!this._denormalised) {
|
|
68
|
+
this.denormalise();
|
|
69
|
+
}
|
|
70
|
+
return this._denormalised;
|
|
71
|
+
}
|
|
72
|
+
group() {
|
|
73
|
+
this._groups = (0, import_groupEntitiesByLayer.default)(this.denormalised);
|
|
74
|
+
return this._groups;
|
|
75
|
+
}
|
|
76
|
+
get groups() {
|
|
77
|
+
if (!this._groups) {
|
|
78
|
+
this.group();
|
|
79
|
+
}
|
|
80
|
+
return this._groups;
|
|
81
|
+
}
|
|
82
|
+
toSVG() {
|
|
83
|
+
return (0, import_toSVG.default)(this.parsed);
|
|
84
|
+
}
|
|
85
|
+
toPolylines() {
|
|
86
|
+
return (0, import_toPolylines.default)(this.parsed);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=Helper.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/Helper.ts"],
|
|
4
|
+
"sourcesContent": ["import denormalise from './denormalise'\nimport groupEntitiesByLayer from './groupEntitiesByLayer'\nimport parseString from './parseString'\nimport toPolylines from './toPolylines'\nimport toSVG from './toSVG'\nimport logger from './util/logger'\n\nimport type { Entity, LayerGroups, ParsedDXF } from './types'\n\nexport default class Helper {\n private readonly _contents: string\n private _parsed: ParsedDXF | null\n private _denormalised: Entity[] | null\n private _groups: LayerGroups | null\n\n constructor(contents: string) {\n if (typeof contents !== 'string') {\n throw new TypeError('Helper constructor expects a DXF string')\n }\n this._contents = contents\n this._parsed = null\n this._denormalised = null\n this._groups = null\n }\n\n parse(): ParsedDXF {\n this._parsed = parseString(this._contents)\n logger.info('parsed:', this.parsed)\n return this._parsed\n }\n\n get parsed(): ParsedDXF {\n if (this._parsed === null) {\n this.parse()\n }\n return this._parsed as ParsedDXF\n }\n\n denormalise(): Entity[] {\n this._denormalised = denormalise(this.parsed)\n logger.info('denormalised:', this._denormalised)\n return this._denormalised\n }\n\n get denormalised(): Entity[] {\n if (!this._denormalised) {\n this.denormalise()\n }\n return this._denormalised as Entity[]\n }\n\n group(): LayerGroups {\n this._groups = groupEntitiesByLayer(this.denormalised)\n return this._groups\n }\n\n get groups(): LayerGroups {\n if (!this._groups) {\n this.group()\n }\n return this._groups as LayerGroups\n }\n\n toSVG(): string {\n return toSVG(this.parsed)\n }\n\n toPolylines(): ReturnType<typeof toPolylines> {\n return toPolylines(this.parsed)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwB;AACxB,kCAAiC;AACjC,yBAAwB;AACxB,yBAAwB;AACxB,mBAAkB;AAClB,oBAAmB;AAInB,MAAO,OAAqB;AAAA,EAM1B,YAAY,UAAkB;AAC5B,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,UAAU,yCAAyC;AAAA,IAC/D;AACA,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,QAAmB;AACjB,SAAK,cAAU,mBAAAA,SAAY,KAAK,SAAS;AACzC,kBAAAC,QAAO,KAAK,WAAW,KAAK,MAAM;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAoB;AACtB,QAAI,KAAK,YAAY,MAAM;AACzB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAwB;AACtB,SAAK,oBAAgB,mBAAAC,SAAY,KAAK,MAAM;AAC5C,kBAAAD,QAAO,KAAK,iBAAiB,KAAK,aAAa;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,eAAyB;AAC3B,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,YAAY;AAAA,IACnB;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAqB;AACnB,SAAK,cAAU,4BAAAE,SAAqB,KAAK,YAAY;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAsB;AACxB,QAAI,CAAC,KAAK,SAAS;AACjB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAgB;AACd,eAAO,aAAAC,SAAM,KAAK,MAAM;AAAA,EAC1B;AAAA,EAEA,cAA8C;AAC5C,eAAO,mBAAAC,SAAY,KAAK,MAAM;AAAA,EAChC;AACF;",
|
|
6
|
+
"names": ["parseString", "logger", "denormalise", "groupEntitiesByLayer", "toSVG", "toPolylines"]
|
|
7
|
+
}
|
package/lib/Helper.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import denormalise from "./denormalise";
|
|
2
|
+
import groupEntitiesByLayer from "./groupEntitiesByLayer";
|
|
3
|
+
import parseString from "./parseString";
|
|
4
|
+
import toPolylines from "./toPolylines";
|
|
5
|
+
import toSVG from "./toSVG";
|
|
6
|
+
import logger from "./util/logger";
|
|
7
|
+
class Helper {
|
|
8
|
+
constructor(contents) {
|
|
9
|
+
if (typeof contents !== "string") {
|
|
10
|
+
throw new TypeError("Helper constructor expects a DXF string");
|
|
11
|
+
}
|
|
12
|
+
this._contents = contents;
|
|
13
|
+
this._parsed = null;
|
|
14
|
+
this._denormalised = null;
|
|
15
|
+
this._groups = null;
|
|
16
|
+
}
|
|
17
|
+
parse() {
|
|
18
|
+
this._parsed = parseString(this._contents);
|
|
19
|
+
logger.info("parsed:", this.parsed);
|
|
20
|
+
return this._parsed;
|
|
21
|
+
}
|
|
22
|
+
get parsed() {
|
|
23
|
+
if (this._parsed === null) {
|
|
24
|
+
this.parse();
|
|
25
|
+
}
|
|
26
|
+
return this._parsed;
|
|
27
|
+
}
|
|
28
|
+
denormalise() {
|
|
29
|
+
this._denormalised = denormalise(this.parsed);
|
|
30
|
+
logger.info("denormalised:", this._denormalised);
|
|
31
|
+
return this._denormalised;
|
|
32
|
+
}
|
|
33
|
+
get denormalised() {
|
|
34
|
+
if (!this._denormalised) {
|
|
35
|
+
this.denormalise();
|
|
36
|
+
}
|
|
37
|
+
return this._denormalised;
|
|
38
|
+
}
|
|
39
|
+
group() {
|
|
40
|
+
this._groups = groupEntitiesByLayer(this.denormalised);
|
|
41
|
+
return this._groups;
|
|
42
|
+
}
|
|
43
|
+
get groups() {
|
|
44
|
+
if (!this._groups) {
|
|
45
|
+
this.group();
|
|
46
|
+
}
|
|
47
|
+
return this._groups;
|
|
48
|
+
}
|
|
49
|
+
toSVG() {
|
|
50
|
+
return toSVG(this.parsed);
|
|
51
|
+
}
|
|
52
|
+
toPolylines() {
|
|
53
|
+
return toPolylines(this.parsed);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
Helper as default
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=Helper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/Helper.ts"],
|
|
4
|
+
"sourcesContent": ["import denormalise from './denormalise'\nimport groupEntitiesByLayer from './groupEntitiesByLayer'\nimport parseString from './parseString'\nimport toPolylines from './toPolylines'\nimport toSVG from './toSVG'\nimport logger from './util/logger'\n\nimport type { Entity, LayerGroups, ParsedDXF } from './types'\n\nexport default class Helper {\n private readonly _contents: string\n private _parsed: ParsedDXF | null\n private _denormalised: Entity[] | null\n private _groups: LayerGroups | null\n\n constructor(contents: string) {\n if (typeof contents !== 'string') {\n throw new TypeError('Helper constructor expects a DXF string')\n }\n this._contents = contents\n this._parsed = null\n this._denormalised = null\n this._groups = null\n }\n\n parse(): ParsedDXF {\n this._parsed = parseString(this._contents)\n logger.info('parsed:', this.parsed)\n return this._parsed\n }\n\n get parsed(): ParsedDXF {\n if (this._parsed === null) {\n this.parse()\n }\n return this._parsed as ParsedDXF\n }\n\n denormalise(): Entity[] {\n this._denormalised = denormalise(this.parsed)\n logger.info('denormalised:', this._denormalised)\n return this._denormalised\n }\n\n get denormalised(): Entity[] {\n if (!this._denormalised) {\n this.denormalise()\n }\n return this._denormalised as Entity[]\n }\n\n group(): LayerGroups {\n this._groups = groupEntitiesByLayer(this.denormalised)\n return this._groups\n }\n\n get groups(): LayerGroups {\n if (!this._groups) {\n this.group()\n }\n return this._groups as LayerGroups\n }\n\n toSVG(): string {\n return toSVG(this.parsed)\n }\n\n toPolylines(): ReturnType<typeof toPolylines> {\n return toPolylines(this.parsed)\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,iBAAiB;AACxB,OAAO,0BAA0B;AACjC,OAAO,iBAAiB;AACxB,OAAO,iBAAiB;AACxB,OAAO,WAAW;AAClB,OAAO,YAAY;AAInB,MAAO,OAAqB;AAAA,EAM1B,YAAY,UAAkB;AAC5B,QAAI,OAAO,aAAa,UAAU;AAChC,YAAM,IAAI,UAAU,yCAAyC;AAAA,IAC/D;AACA,SAAK,YAAY;AACjB,SAAK,UAAU;AACf,SAAK,gBAAgB;AACrB,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,QAAmB;AACjB,SAAK,UAAU,YAAY,KAAK,SAAS;AACzC,WAAO,KAAK,WAAW,KAAK,MAAM;AAClC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAoB;AACtB,QAAI,KAAK,YAAY,MAAM;AACzB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,cAAwB;AACtB,SAAK,gBAAgB,YAAY,KAAK,MAAM;AAC5C,WAAO,KAAK,iBAAiB,KAAK,aAAa;AAC/C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,eAAyB;AAC3B,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,YAAY;AAAA,IACnB;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAqB;AACnB,SAAK,UAAU,qBAAqB,KAAK,YAAY;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAsB;AACxB,QAAI,CAAC,KAAK,SAAS;AACjB,WAAK,MAAM;AAAA,IACb;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAgB;AACd,WAAO,MAAM,KAAK,MAAM;AAAA,EAC1B;AAAA,EAEA,cAA8C;AAC5C,WAAO,YAAY,KAAK,MAAM;AAAA,EAChC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var applyTransforms_exports = {};
|
|
20
|
+
__export(applyTransforms_exports, {
|
|
21
|
+
default: () => applyTransforms
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(applyTransforms_exports);
|
|
24
|
+
function applyTransforms(polyline, transforms) {
|
|
25
|
+
if (!transforms) {
|
|
26
|
+
return polyline;
|
|
27
|
+
}
|
|
28
|
+
let result = polyline;
|
|
29
|
+
for (const transform of transforms) {
|
|
30
|
+
result = result.map((p) => {
|
|
31
|
+
let p2 = [p[0], p[1]];
|
|
32
|
+
if (transform.scaleX) {
|
|
33
|
+
p2[0] = p2[0] * transform.scaleX;
|
|
34
|
+
}
|
|
35
|
+
if (transform.scaleY) {
|
|
36
|
+
p2[1] = p2[1] * transform.scaleY;
|
|
37
|
+
}
|
|
38
|
+
if (transform.rotation) {
|
|
39
|
+
const angle = transform.rotation / 180 * Math.PI;
|
|
40
|
+
p2 = [
|
|
41
|
+
p2[0] * Math.cos(angle) - p2[1] * Math.sin(angle),
|
|
42
|
+
p2[1] * Math.cos(angle) + p2[0] * Math.sin(angle)
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
if (transform.x) {
|
|
46
|
+
p2[0] = p2[0] + transform.x;
|
|
47
|
+
}
|
|
48
|
+
if (transform.y) {
|
|
49
|
+
p2[1] = p2[1] + transform.y;
|
|
50
|
+
}
|
|
51
|
+
if (transform.extrusionZ === -1) {
|
|
52
|
+
p2[0] = -p2[0];
|
|
53
|
+
}
|
|
54
|
+
return p2;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=applyTransforms.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/applyTransforms.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Apply the transforms to the polyline.\n *\n * @param polyline the polyline\n * @param transforms the transforms array\n * @returns the transformed polyline\n */\n\nimport type { PointTuple, Transform } from './types'\n\ntype Point = PointTuple\n\nexport default function applyTransforms(\n polyline: Point[],\n transforms?: Transform[],\n): Point[] {\n if (!transforms) {\n return polyline\n }\n\n let result = polyline\n for (const transform of transforms) {\n result = result.map((p) => {\n // Use a copy to avoid side effects\n let p2: Point = [p[0], p[1]]\n if (transform.scaleX) {\n p2[0] = p2[0] * transform.scaleX\n }\n if (transform.scaleY) {\n p2[1] = p2[1] * transform.scaleY\n }\n if (transform.rotation) {\n const angle = (transform.rotation / 180) * Math.PI\n p2 = [\n p2[0] * Math.cos(angle) - p2[1] * Math.sin(angle),\n p2[1] * Math.cos(angle) + p2[0] * Math.sin(angle),\n ]\n }\n if (transform.x) {\n p2[0] = p2[0] + transform.x\n }\n if (transform.y) {\n p2[1] = p2[1] + transform.y\n }\n // Observed once in a sample DXF - some cad applications\n // use negative extruxion Z for flipping\n if (transform.extrusionZ === -1) {\n p2[0] = -p2[0]\n }\n return p2\n })\n }\n return result\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYe,SAAR,gBACL,UACA,YACS;AACT,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,aAAW,aAAa,YAAY;AAClC,aAAS,OAAO,IAAI,CAAC,MAAM;AAEzB,UAAI,KAAY,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAC3B,UAAI,UAAU,QAAQ;AACpB,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AACA,UAAI,UAAU,QAAQ;AACpB,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AACA,UAAI,UAAU,UAAU;AACtB,cAAM,QAAS,UAAU,WAAW,MAAO,KAAK;AAChD,aAAK;AAAA,UACH,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK;AAAA,UAChD,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK;AAAA,QAClD;AAAA,MACF;AACA,UAAI,UAAU,GAAG;AACf,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AACA,UAAI,UAAU,GAAG;AACf,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AAGA,UAAI,UAAU,eAAe,IAAI;AAC/B,WAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AAAA,MACf;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function applyTransforms(polyline, transforms) {
|
|
2
|
+
if (!transforms) {
|
|
3
|
+
return polyline;
|
|
4
|
+
}
|
|
5
|
+
let result = polyline;
|
|
6
|
+
for (const transform of transforms) {
|
|
7
|
+
result = result.map((p) => {
|
|
8
|
+
let p2 = [p[0], p[1]];
|
|
9
|
+
if (transform.scaleX) {
|
|
10
|
+
p2[0] = p2[0] * transform.scaleX;
|
|
11
|
+
}
|
|
12
|
+
if (transform.scaleY) {
|
|
13
|
+
p2[1] = p2[1] * transform.scaleY;
|
|
14
|
+
}
|
|
15
|
+
if (transform.rotation) {
|
|
16
|
+
const angle = transform.rotation / 180 * Math.PI;
|
|
17
|
+
p2 = [
|
|
18
|
+
p2[0] * Math.cos(angle) - p2[1] * Math.sin(angle),
|
|
19
|
+
p2[1] * Math.cos(angle) + p2[0] * Math.sin(angle)
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
if (transform.x) {
|
|
23
|
+
p2[0] = p2[0] + transform.x;
|
|
24
|
+
}
|
|
25
|
+
if (transform.y) {
|
|
26
|
+
p2[1] = p2[1] + transform.y;
|
|
27
|
+
}
|
|
28
|
+
if (transform.extrusionZ === -1) {
|
|
29
|
+
p2[0] = -p2[0];
|
|
30
|
+
}
|
|
31
|
+
return p2;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
applyTransforms as default
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=applyTransforms.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/applyTransforms.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Apply the transforms to the polyline.\n *\n * @param polyline the polyline\n * @param transforms the transforms array\n * @returns the transformed polyline\n */\n\nimport type { PointTuple, Transform } from './types'\n\ntype Point = PointTuple\n\nexport default function applyTransforms(\n polyline: Point[],\n transforms?: Transform[],\n): Point[] {\n if (!transforms) {\n return polyline\n }\n\n let result = polyline\n for (const transform of transforms) {\n result = result.map((p) => {\n // Use a copy to avoid side effects\n let p2: Point = [p[0], p[1]]\n if (transform.scaleX) {\n p2[0] = p2[0] * transform.scaleX\n }\n if (transform.scaleY) {\n p2[1] = p2[1] * transform.scaleY\n }\n if (transform.rotation) {\n const angle = (transform.rotation / 180) * Math.PI\n p2 = [\n p2[0] * Math.cos(angle) - p2[1] * Math.sin(angle),\n p2[1] * Math.cos(angle) + p2[0] * Math.sin(angle),\n ]\n }\n if (transform.x) {\n p2[0] = p2[0] + transform.x\n }\n if (transform.y) {\n p2[1] = p2[1] + transform.y\n }\n // Observed once in a sample DXF - some cad applications\n // use negative extruxion Z for flipping\n if (transform.extrusionZ === -1) {\n p2[0] = -p2[0]\n }\n return p2\n })\n }\n return result\n}\n"],
|
|
5
|
+
"mappings": "AAYe,SAAR,gBACL,UACA,YACS;AACT,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AAEA,MAAI,SAAS;AACb,aAAW,aAAa,YAAY;AAClC,aAAS,OAAO,IAAI,CAAC,MAAM;AAEzB,UAAI,KAAY,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAC3B,UAAI,UAAU,QAAQ;AACpB,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AACA,UAAI,UAAU,QAAQ;AACpB,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AACA,UAAI,UAAU,UAAU;AACtB,cAAM,QAAS,UAAU,WAAW,MAAO,KAAK;AAChD,aAAK;AAAA,UACH,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK;AAAA,UAChD,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK;AAAA,QAClD;AAAA,MACF;AACA,UAAI,UAAU,GAAG;AACf,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AACA,UAAI,UAAU,GAAG;AACf,WAAG,CAAC,IAAI,GAAG,CAAC,IAAI,UAAU;AAAA,MAC5B;AAGA,UAAI,UAAU,eAAe,IAAI;AAC/B,WAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AAAA,MACf;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/lib/cli.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
var import_commander = require("commander");
|
|
26
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
27
|
+
var import_node_module = require("node:module");
|
|
28
|
+
var import__ = require("./");
|
|
29
|
+
const import_meta = {};
|
|
30
|
+
const require2 = (0, import_node_module.createRequire)(
|
|
31
|
+
typeof __filename === "string" ? __filename : import_meta.url
|
|
32
|
+
);
|
|
33
|
+
const { version } = require2("../package.json");
|
|
34
|
+
const program = new import_commander.Command();
|
|
35
|
+
program.version(version).description("Converts a dxf file to a svg file.").arguments("<dxfFile> [svgFile]").option("-v --verbose", "Verbose output").action((dxfFile, svgFile, options) => {
|
|
36
|
+
const parsed = (0, import__.parseString)(import_node_fs.default.readFileSync(dxfFile, "utf-8"));
|
|
37
|
+
if (options.verbose) {
|
|
38
|
+
const groups = (0, import__.groupEntitiesByLayer)((0, import__.denormalise)(parsed));
|
|
39
|
+
console.log("[layer : number of entities]");
|
|
40
|
+
for (const layer of Object.keys(groups)) {
|
|
41
|
+
console.log(`${layer} : ${groups[layer].length}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
import_node_fs.default.writeFileSync(
|
|
45
|
+
svgFile || `${dxfFile.split(".").slice(0, -1).join(".")}.svg`,
|
|
46
|
+
(0, import__.toSVG)(parsed),
|
|
47
|
+
"utf-8"
|
|
48
|
+
);
|
|
49
|
+
}).parse(process.argv);
|
|
50
|
+
if (!process.argv.slice(2).length) {
|
|
51
|
+
program.help();
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=cli.cjs.map
|
package/lib/cli.cjs.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\nimport { Command } from 'commander'\nimport fs from 'node:fs'\nimport { createRequire } from 'node:module'\n\nimport { denormalise, groupEntitiesByLayer, parseString, toSVG } from './'\n\nconst require = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url,\n)\nconst { version } = require('../package.json')\n\nconst program = new Command()\n\nprogram\n .version(version)\n .description('Converts a dxf file to a svg file.')\n .arguments('<dxfFile> [svgFile]')\n .option('-v --verbose', 'Verbose output')\n .action((dxfFile: string, svgFile: string | undefined, options: { verbose?: boolean }) => {\n const parsed = parseString(fs.readFileSync(dxfFile, 'utf-8'))\n\n if (options.verbose) {\n const groups = groupEntitiesByLayer(denormalise(parsed))\n console.log('[layer : number of entities]')\n for (const layer of Object.keys(groups)) {\n console.log(`${layer} : ${groups[layer].length}`)\n }\n }\n\n fs.writeFileSync(\n svgFile || `${dxfFile.split('.').slice(0, -1).join('.')}.svg`,\n toSVG(parsed),\n 'utf-8',\n )\n })\n .parse(process.argv)\n\nif (!process.argv.slice(2).length) {\n program.help()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AACA,uBAAwB;AACxB,qBAAe;AACf,yBAA8B;AAE9B,eAAsE;AALtE;AAOA,MAAMA,eAAU;AAAA,EACd,OAAO,eAAe,WAAW,aAAa,YAAY;AAC5D;AACA,MAAM,EAAE,QAAQ,IAAIA,SAAQ,iBAAiB;AAE7C,MAAM,UAAU,IAAI,yBAAQ;AAE5B,QACG,QAAQ,OAAO,EACf,YAAY,oCAAoC,EAChD,UAAU,qBAAqB,EAC/B,OAAO,gBAAgB,gBAAgB,EACvC,OAAO,CAAC,SAAiB,SAA6B,YAAmC;AACxF,QAAM,aAAS,sBAAY,eAAAC,QAAG,aAAa,SAAS,OAAO,CAAC;AAE5D,MAAI,QAAQ,SAAS;AACnB,UAAM,aAAS,mCAAqB,sBAAY,MAAM,CAAC;AACvD,YAAQ,IAAI,8BAA8B;AAC1C,eAAW,SAAS,OAAO,KAAK,MAAM,GAAG;AACvC,cAAQ,IAAI,GAAG,KAAK,MAAM,OAAO,KAAK,EAAE,MAAM,EAAE;AAAA,IAClD;AAAA,EACF;AAEA,iBAAAA,QAAG;AAAA,IACD,WAAW,GAAG,QAAQ,MAAM,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC;AAAA,QACvD,gBAAM,MAAM;AAAA,IACZ;AAAA,EACF;AACF,CAAC,EACA,MAAM,QAAQ,IAAI;AAErB,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,UAAQ,KAAK;AACf;",
|
|
6
|
+
"names": ["require", "fs"]
|
|
7
|
+
}
|
package/lib/cli.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { denormalise, groupEntitiesByLayer, parseString, toSVG } from "./";
|
|
6
|
+
const require2 = createRequire(
|
|
7
|
+
typeof __filename === "string" ? __filename : import.meta.url
|
|
8
|
+
);
|
|
9
|
+
const { version } = require2("../package.json");
|
|
10
|
+
const program = new Command();
|
|
11
|
+
program.version(version).description("Converts a dxf file to a svg file.").arguments("<dxfFile> [svgFile]").option("-v --verbose", "Verbose output").action((dxfFile, svgFile, options) => {
|
|
12
|
+
const parsed = parseString(fs.readFileSync(dxfFile, "utf-8"));
|
|
13
|
+
if (options.verbose) {
|
|
14
|
+
const groups = groupEntitiesByLayer(denormalise(parsed));
|
|
15
|
+
console.log("[layer : number of entities]");
|
|
16
|
+
for (const layer of Object.keys(groups)) {
|
|
17
|
+
console.log(`${layer} : ${groups[layer].length}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
fs.writeFileSync(
|
|
21
|
+
svgFile || `${dxfFile.split(".").slice(0, -1).join(".")}.svg`,
|
|
22
|
+
toSVG(parsed),
|
|
23
|
+
"utf-8"
|
|
24
|
+
);
|
|
25
|
+
}).parse(process.argv);
|
|
26
|
+
if (!process.argv.slice(2).length) {
|
|
27
|
+
program.help();
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\nimport { Command } from 'commander'\nimport fs from 'node:fs'\nimport { createRequire } from 'node:module'\n\nimport { denormalise, groupEntitiesByLayer, parseString, toSVG } from './'\n\nconst require = createRequire(\n typeof __filename === 'string' ? __filename : import.meta.url,\n)\nconst { version } = require('../package.json')\n\nconst program = new Command()\n\nprogram\n .version(version)\n .description('Converts a dxf file to a svg file.')\n .arguments('<dxfFile> [svgFile]')\n .option('-v --verbose', 'Verbose output')\n .action((dxfFile: string, svgFile: string | undefined, options: { verbose?: boolean }) => {\n const parsed = parseString(fs.readFileSync(dxfFile, 'utf-8'))\n\n if (options.verbose) {\n const groups = groupEntitiesByLayer(denormalise(parsed))\n console.log('[layer : number of entities]')\n for (const layer of Object.keys(groups)) {\n console.log(`${layer} : ${groups[layer].length}`)\n }\n }\n\n fs.writeFileSync(\n svgFile || `${dxfFile.split('.').slice(0, -1).join('.')}.svg`,\n toSVG(parsed),\n 'utf-8',\n )\n })\n .parse(process.argv)\n\nif (!process.argv.slice(2).length) {\n program.help()\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,eAAe;AACxB,OAAO,QAAQ;AACf,SAAS,qBAAqB;AAE9B,SAAS,aAAa,sBAAsB,aAAa,aAAa;AAEtE,MAAMA,WAAU;AAAA,EACd,OAAO,eAAe,WAAW,aAAa,YAAY;AAC5D;AACA,MAAM,EAAE,QAAQ,IAAIA,SAAQ,iBAAiB;AAE7C,MAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,QAAQ,OAAO,EACf,YAAY,oCAAoC,EAChD,UAAU,qBAAqB,EAC/B,OAAO,gBAAgB,gBAAgB,EACvC,OAAO,CAAC,SAAiB,SAA6B,YAAmC;AACxF,QAAM,SAAS,YAAY,GAAG,aAAa,SAAS,OAAO,CAAC;AAE5D,MAAI,QAAQ,SAAS;AACnB,UAAM,SAAS,qBAAqB,YAAY,MAAM,CAAC;AACvD,YAAQ,IAAI,8BAA8B;AAC1C,eAAW,SAAS,OAAO,KAAK,MAAM,GAAG;AACvC,cAAQ,IAAI,GAAG,KAAK,MAAM,OAAO,KAAK,EAAE,MAAM,EAAE;AAAA,IAClD;AAAA,EACF;AAEA,KAAG;AAAA,IACD,WAAW,GAAG,QAAQ,MAAM,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC;AAAA,IACvD,MAAM,MAAM;AAAA,IACZ;AAAA,EACF;AACF,CAAC,EACA,MAAM,QAAQ,IAAI;AAErB,IAAI,CAAC,QAAQ,KAAK,MAAM,CAAC,EAAE,QAAQ;AACjC,UAAQ,KAAK;AACf;",
|
|
6
|
+
"names": ["require"]
|
|
7
|
+
}
|