@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
package/README.md
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
[](https://travis-ci.org/bjnortier/dxf)
|
|
2
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
3
|
+
|
|
4
|
+
# DXF-Renewed
|
|
5
|
+
|
|
6
|
+
> **⚠️ WARNING: This repository is currently under development and has not been fully tested in production. Use at your own risk.**
|
|
7
|
+
|
|
8
|
+
DXF parser for node/browser.
|
|
9
|
+
|
|
10
|
+
Written in **TypeScript** with full type definitions included. Uses modern ES2015+ features and is built with esbuild for optimal performance.
|
|
11
|
+
|
|
12
|
+
> **Note:** This is a renewed and modernized fork of the original [dxf](https://github.com/skymakerolof/dxf) library, with complete TypeScript migration, enhanced performance, and additional features.
|
|
13
|
+
|
|
14
|
+
## Version History
|
|
15
|
+
|
|
16
|
+
**Version 2.0** - Complete rewrite from SAX-style parsing to handle nested references properly (inserts, blocks, etc.)
|
|
17
|
+
|
|
18
|
+
**Version 3.0** - Adopted [standard JS](https://standardjs.com), ES6 imports, removed Gulp, updated dependencies
|
|
19
|
+
|
|
20
|
+
**Version 4.x** - Native SVG elements where possible (`<circle />`, `<ellipse />`, etc.)
|
|
21
|
+
|
|
22
|
+
**Version 5.x (Current)** - Complete TypeScript migration:
|
|
23
|
+
|
|
24
|
+
- 🎯 Full TypeScript codebase with strict type checking
|
|
25
|
+
- ⚡ Built with esbuild (96% faster than Babel - 18ms vs 447ms)
|
|
26
|
+
- 📦 Modular type system with 22+ separate type files
|
|
27
|
+
- ✅ 100% test coverage maintained (85 tests passing)
|
|
28
|
+
- 🎨 Enhanced SVG rendering with TEXT, MTEXT, and DIMENSION support
|
|
29
|
+
- 📚 Comprehensive type definitions for all DXF entities
|
|
30
|
+
|
|
31
|
+
## Supported Entities
|
|
32
|
+
|
|
33
|
+
All major geometric entities are **parsed and rendered to SVG**:
|
|
34
|
+
|
|
35
|
+
### Fully Supported
|
|
36
|
+
|
|
37
|
+
- ✅ **LINE** - Straight line segments
|
|
38
|
+
- ✅ **CIRCLE** - Native SVG `<circle />` element
|
|
39
|
+
- ✅ **ARC** - Circular arcs with native SVG paths
|
|
40
|
+
- ✅ **ELLIPSE** - Native SVG `<ellipse />` element
|
|
41
|
+
- ✅ **LWPOLYLINE** - Lightweight polylines with bulges
|
|
42
|
+
- ✅ **POLYLINE** - 2D/3D polylines with vertices
|
|
43
|
+
- ✅ **SPLINE** - B-spline curves (degree 2-3 as Bézier, others interpolated)
|
|
44
|
+
- ✅ **TEXT** - Single-line text with rotation
|
|
45
|
+
- ✅ **MTEXT** - Multi-line text with formatting
|
|
46
|
+
- ✅ **DIMENSION** - Linear, aligned, radial, diameter, and ordinate dimensions
|
|
47
|
+
- ✅ **INSERT** - Block references with transformations
|
|
48
|
+
- ✅ **POINT** - Point entities
|
|
49
|
+
- ✅ **SOLID** - Solid-filled triangles and quadrilaterals
|
|
50
|
+
- ✅ **3DFACE** - 3D face entities
|
|
51
|
+
|
|
52
|
+
### Parsed (Not Rendered)
|
|
53
|
+
|
|
54
|
+
- ⚠️ **HATCH** - Parsed but not rendered to SVG
|
|
55
|
+
- ⚠️ **STYLE** - Text styles parsed (colors supported, fonts not applied)
|
|
56
|
+
- ⚠️ **ATTDEF/ATTRIB** - Block attributes parsed
|
|
57
|
+
|
|
58
|
+
## Getting started
|
|
59
|
+
|
|
60
|
+
TypeScript example with full type safety:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { Helper } from '@linkiez/dxf-renew'
|
|
64
|
+
|
|
65
|
+
const helper = new Helper(dxfString)
|
|
66
|
+
|
|
67
|
+
// The 1-to-1 object representation of the DXF
|
|
68
|
+
console.log('parsed:', helper.parsed)
|
|
69
|
+
|
|
70
|
+
// Denormalised blocks inserted with transforms applied
|
|
71
|
+
console.log('denormalised:', helper.denormalised)
|
|
72
|
+
|
|
73
|
+
// Create an SVG
|
|
74
|
+
console.log('svg:', helper.toSVG())
|
|
75
|
+
|
|
76
|
+
// Create polylines (e.g. to render in WebGL)
|
|
77
|
+
console.log('polylines:', helper.toPolylines())
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
JavaScript example:
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
const { Helper } = require('@linkiez/dxf-renew')
|
|
84
|
+
|
|
85
|
+
const helper = new Helper(dxfString)
|
|
86
|
+
|
|
87
|
+
// The 1-to-1 object representation of the DXF
|
|
88
|
+
console.log('parsed:', helper.parsed)
|
|
89
|
+
|
|
90
|
+
// Denormalised blocks inserted with transforms applied
|
|
91
|
+
console.log('denormalised:', helper.denormalised)
|
|
92
|
+
|
|
93
|
+
// Create an SVG
|
|
94
|
+
console.log('svg:', helper.toSVG())
|
|
95
|
+
|
|
96
|
+
// Create polylines (e.g. to render in WebGL)
|
|
97
|
+
console.log('polylines:', helper.toPolylines())
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Running the Examples
|
|
101
|
+
|
|
102
|
+
There are examples in the `examples/` directory.
|
|
103
|
+
|
|
104
|
+
Node ES6 (TypeScript). Will write an SVG to `examples/example.es6.svg`:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx tsx examples/example.es6.js
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Node ES5. Will write an SVG to `examples/example.es5.svg`:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
node examples/example.es5.js
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Browser. Compile to a browser bundle and open the example webpage:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
yarn compile
|
|
120
|
+
open examples/dxf.html
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Package Manager
|
|
124
|
+
|
|
125
|
+
This project uses **Yarn 4** (Berry) as the package manager. Make sure you have Yarn installed:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Install via npm
|
|
129
|
+
npm install -g yarn
|
|
130
|
+
|
|
131
|
+
# Or via corepack (recommended)
|
|
132
|
+
corepack enable
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
All npm commands in the documentation can be replaced with yarn equivalents:
|
|
136
|
+
|
|
137
|
+
- `npm install` → `yarn install` or just `yarn`
|
|
138
|
+
- `npm test` → `yarn test`
|
|
139
|
+
- `npm run compile` → `yarn compile`
|
|
140
|
+
|
|
141
|
+
## SVG
|
|
142
|
+
|
|
143
|
+
Geometric elements are fully supported with **native SVG elements** where possible (`<circle />`, `<ellipse/>`, etc.). TEXT, MTEXT, and DIMENSION entities are now fully rendered with proper transformations and formatting.
|
|
144
|
+
|
|
145
|
+
**SPLINE entities** with degree 2-3 and no weights are converted to native Bézier curves. Other splines are interpolated as polylines.
|
|
146
|
+
|
|
147
|
+
Here's an example you will find in the functional test output:
|
|
148
|
+
|
|
149
|
+

|
|
150
|
+
|
|
151
|
+
## Interpolation
|
|
152
|
+
|
|
153
|
+
The library supports outputting DXFs as interpolated polylines for custom rendering (e.g. WebGL) or other applications:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
const polylines = helper.toPolylines()
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Command line
|
|
160
|
+
|
|
161
|
+
There is a command-line utility (courtesy of [@Joge97](https://github.com/Joge97)) for converting DXF files to SVG:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
yarn global add @linkiez/dxf-renew
|
|
165
|
+
# or
|
|
166
|
+
npm i -g @linkiez/dxf-renew
|
|
167
|
+
|
|
168
|
+
dxf-to-svg --help
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Usage:
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
Usage: dxf-to-svg [options] <dxfFile> [svgFile]
|
|
175
|
+
|
|
176
|
+
Converts a dxf file to a svg file.
|
|
177
|
+
|
|
178
|
+
Options:
|
|
179
|
+
-V, --version output the version number
|
|
180
|
+
-v --verbose Verbose output
|
|
181
|
+
-h, --help output usage information
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Tests
|
|
185
|
+
|
|
186
|
+
Running the unit tests:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
yarn test
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Running the functional tests in a browser:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
yarn test:functional
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Please open `toSVG.html` when the file listing loads in the browser (or open `http://localhost:8030/toSVG.html#/`).
|
|
199
|
+
|
|
200
|
+
## Development Guidelines
|
|
201
|
+
|
|
202
|
+
- Code patterns and best practices: `docs/CODE_PATTERNS.md`
|
|
203
|
+
|
|
204
|
+
## TypeScript Support
|
|
205
|
+
|
|
206
|
+
This library is written in TypeScript and includes full type definitions. All DXF entities, configuration options, and helper methods are fully typed.
|
|
207
|
+
|
|
208
|
+
Example with type imports:
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
import { Helper, ParsedDXF, Entity, LineEntity, CircleEntity } from '@linkiez/dxf-renew'
|
|
212
|
+
|
|
213
|
+
const helper = new Helper(dxfString)
|
|
214
|
+
const parsed: ParsedDXF = helper.parsed
|
|
215
|
+
const entities: Entity[] = helper.denormalised
|
|
216
|
+
|
|
217
|
+
// Type narrowing
|
|
218
|
+
entities.forEach((entity) => {
|
|
219
|
+
if (entity.type === 'LINE') {
|
|
220
|
+
const line = entity as LineEntity
|
|
221
|
+
console.log(`Line from (${line.start.x}, ${line.start.y}) to (${line.end.x}, ${line.end.y})`)
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Build System
|
|
227
|
+
|
|
228
|
+
The project uses **esbuild** for compilation, which is significantly faster than Babel:
|
|
229
|
+
|
|
230
|
+
- Build time: ~18-22ms (vs 447ms with Babel)
|
|
231
|
+
- 96% performance improvement
|
|
232
|
+
- Full TypeScript support with type checking via `tsc`
|
|
233
|
+
- **Yarn 4** (Berry) as package manager
|
|
234
|
+
|
|
235
|
+
Build commands:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
yarn compile # Compile TypeScript to JavaScript
|
|
239
|
+
yarn type-check # Run TypeScript type checking
|
|
240
|
+
yarn test # Run all tests
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Credits
|
|
244
|
+
|
|
245
|
+
This project is a modernized fork of the original [dxf library by skymakerolof](https://github.com/skymakerolof/dxf), which itself was based on the work by bjnortier and many contributors. DXF-Renewed aims to maintain and improve upon this excellent foundation with modern TypeScript, enhanced performance, and new features.
|
|
246
|
+
|
|
247
|
+
## Releases
|
|
248
|
+
|
|
249
|
+
This project uses [semantic-release](https://semantic-release.gitbook.io/) for automated version management and package publishing.
|
|
250
|
+
|
|
251
|
+
**Releases are automatically created** when commits following [Conventional Commits](https://www.conventionalcommits.org/en/) are pushed to:
|
|
252
|
+
|
|
253
|
+
- `main` - Stable production releases (`1.0.0`, `1.1.0`, `2.0.0`)
|
|
254
|
+
- `develop` - Pre-releases for testing (`1.1.0-dev.1`, `1.1.0-dev.2`)
|
|
255
|
+
- `beta` - Beta pre-releases (`1.1.0-beta.1`, `1.1.0-beta.2`)
|
|
256
|
+
|
|
257
|
+
### Commit Format
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# New feature → MINOR version (1.0.0 → 1.1.0)
|
|
261
|
+
feat(dimension): add DIMSTYLE color support
|
|
262
|
+
|
|
263
|
+
# Bug fix → PATCH version (1.0.0 → 1.0.1)
|
|
264
|
+
fix(parser): correct POLYLINE parsing
|
|
265
|
+
|
|
266
|
+
# Breaking change → MAJOR version (1.0.0 → 2.0.0)
|
|
267
|
+
feat!: migrate to pure ESM
|
|
268
|
+
|
|
269
|
+
BREAKING CHANGE: CommonJS is no longer supported
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Contributing
|
|
273
|
+
|
|
274
|
+
To contribute:
|
|
275
|
+
|
|
276
|
+
1. Fork the repository
|
|
277
|
+
2. Make commits using `yarn commit` (interactive) or following Conventional Commits
|
|
278
|
+
3. Push to your fork
|
|
279
|
+
4. Open a Pull Request to `develop`
|
|
280
|
+
|
|
281
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines and [docs/SEMANTIC_RELEASE.md](./docs/SEMANTIC_RELEASE.md) for release documentation.
|
|
282
|
+
|
|
283
|
+
## Contributors
|
|
284
|
+
|
|
285
|
+
### Original dxf Library Contributors
|
|
286
|
+
|
|
287
|
+
- Liam Mitchell <https://github.com/LiamKarlMitchell>
|
|
288
|
+
- Artur Zochniak <https://github.com/arjamizo>
|
|
289
|
+
- Andy Werner <https://github.com/Gallore>
|
|
290
|
+
- Ivan Baktsheev <https://github.com/apla>
|
|
291
|
+
- Jeff Chen <https://github.com/jeffontheground>
|
|
292
|
+
- Markko Paas <https://github.com/markkopaas>
|
|
293
|
+
- Kim Lokøy <https://github.com/klokoy>
|
|
294
|
+
- Erik Söhnel <https://github.com/hoeck>
|
|
295
|
+
- Teja <https://github.com/hungerpirat>
|
|
296
|
+
- Jakob Pallhuber <https://github.com/Joge97>
|
|
297
|
+
- Eric Mansfield <https://github.com/ericman314>
|
|
298
|
+
- Kristofer <https://github.com/kriffe>
|
|
299
|
+
|
|
300
|
+
### DXF-Renewed Maintainers
|
|
301
|
+
|
|
302
|
+
- LiNkIeZ <https://github.com/linkiez>
|
|
303
|
+
|
|
304
|
+
## License
|
|
305
|
+
|
|
306
|
+
See LICENSE file for details.
|
package/build.mjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// esbuild configuration for building the project
|
|
2
|
+
import * as esbuild from 'esbuild'
|
|
3
|
+
import { readdir } from 'node:fs/promises'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
|
|
6
|
+
async function getEntryPoints(dir) {
|
|
7
|
+
const entries = []
|
|
8
|
+
const stack = [dir]
|
|
9
|
+
|
|
10
|
+
while (stack.length) {
|
|
11
|
+
const currentDir = stack.pop()
|
|
12
|
+
const dirEntries = await readdir(currentDir, { withFileTypes: true })
|
|
13
|
+
|
|
14
|
+
for (const entry of dirEntries) {
|
|
15
|
+
const fullPath = join(currentDir, entry.name)
|
|
16
|
+
|
|
17
|
+
if (entry.isDirectory()) {
|
|
18
|
+
stack.push(fullPath)
|
|
19
|
+
continue
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (entry.isFile() && (entry.name.endsWith('.ts') || entry.name.endsWith('.js'))) {
|
|
23
|
+
entries.push(fullPath)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return entries
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function build() {
|
|
32
|
+
const entryPoints = await getEntryPoints('src')
|
|
33
|
+
|
|
34
|
+
// Build ESM version
|
|
35
|
+
await esbuild.build({
|
|
36
|
+
entryPoints,
|
|
37
|
+
outdir: 'lib',
|
|
38
|
+
platform: 'node',
|
|
39
|
+
format: 'esm',
|
|
40
|
+
target: 'es2020',
|
|
41
|
+
sourcemap: true,
|
|
42
|
+
outExtension: { '.js': '.js' },
|
|
43
|
+
logLevel: 'info',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Build CommonJS version for backwards compatibility
|
|
47
|
+
await esbuild.build({
|
|
48
|
+
entryPoints,
|
|
49
|
+
outdir: 'lib',
|
|
50
|
+
platform: 'node',
|
|
51
|
+
format: 'cjs',
|
|
52
|
+
target: 'es2020',
|
|
53
|
+
sourcemap: true,
|
|
54
|
+
outExtension: { '.js': '.cjs' },
|
|
55
|
+
logLevel: 'info',
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
console.log('✓ Build completed successfully (ESM + CJS)')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
await build()
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Build failed:', error)
|
|
65
|
+
process.exit(1)
|
|
66
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
extends: ['@commitlint/config-conventional'],
|
|
3
|
+
rules: {
|
|
4
|
+
'type-enum': [
|
|
5
|
+
2,
|
|
6
|
+
'always',
|
|
7
|
+
[
|
|
8
|
+
'feat', // New feature
|
|
9
|
+
'fix', // Bug fix
|
|
10
|
+
'docs', // Documentation only
|
|
11
|
+
'style', // Changes that don't affect code meaning (spaces, formatting, etc)
|
|
12
|
+
'refactor', // Code refactoring that neither adds features nor fixes bugs
|
|
13
|
+
'perf', // Performance improvement
|
|
14
|
+
'test', // Adding or correcting tests
|
|
15
|
+
'build', // Changes to build system or external dependencies
|
|
16
|
+
'ci', // Changes to CI files and scripts
|
|
17
|
+
'chore', // Other changes that don't modify src or test files
|
|
18
|
+
'revert' // Reverts a previous commit
|
|
19
|
+
]
|
|
20
|
+
],
|
|
21
|
+
'subject-case': [0], // Allow any capitalization in subject
|
|
22
|
+
'header-max-length': [2, 'always', 100],
|
|
23
|
+
'body-max-line-length': [2, 'always', 100]
|
|
24
|
+
}
|
|
25
|
+
};
|