@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.
Files changed (447) hide show
  1. package/.eslintignore +17 -0
  2. package/.eslintrc.json +61 -0
  3. package/.gitattributes +4 -0
  4. package/.github/instructions/project-en_US.instructions.md +352 -0
  5. package/.github/workflows/release.yml +110 -0
  6. package/.husky/commit-msg +4 -0
  7. package/.husky/pre-commit +1 -0
  8. package/.prettierignore +1 -0
  9. package/.prettierrc.json +6 -0
  10. package/.releaserc.json +76 -0
  11. package/.travis.yml +6 -0
  12. package/.yarn/install-state.gz +0 -0
  13. package/.yarnrc.yml +1 -0
  14. package/CHANGELOG.md +134 -0
  15. package/CONTRIBUTING.md +271 -0
  16. package/LICENSE +21 -0
  17. package/PLAN.md +517 -0
  18. package/README.md +306 -0
  19. package/build.mjs +66 -0
  20. package/commitlint.config.js +25 -0
  21. package/dist/dxf.js +7234 -0
  22. package/docs/CODE_PATTERNS.md +182 -0
  23. package/docs/DIMENSION_SUMMARY.md +248 -0
  24. package/docs/DIMENSION_SUMMARY.pt-BR.md +248 -0
  25. package/docs/IMPLEMENTED-2D-ENTITIES.md +54 -0
  26. package/docs/IMPLEMENTED-2D-ENTITIES.pt-BR.md +54 -0
  27. package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.md +241 -0
  28. package/docs/TEXT-MTEXT-DIMENSION-SUPPORT.pt-BR.md +169 -0
  29. package/docs/autocad_2012_pdf_dxf-reference_enu.md +8272 -0
  30. package/examples/dxf.html +36 -0
  31. package/examples/example.es5.js +30 -0
  32. package/examples/example.es6.js +30 -0
  33. package/examples/text-dimension-viewer.html +133 -0
  34. package/lib/Helper.cjs +89 -0
  35. package/lib/Helper.cjs.map +7 -0
  36. package/lib/Helper.js +59 -0
  37. package/lib/Helper.js.map +7 -0
  38. package/lib/applyTransforms.cjs +59 -0
  39. package/lib/applyTransforms.cjs.map +7 -0
  40. package/lib/applyTransforms.js +39 -0
  41. package/lib/applyTransforms.js.map +7 -0
  42. package/lib/cli.cjs +53 -0
  43. package/lib/cli.cjs.map +7 -0
  44. package/lib/cli.js +29 -0
  45. package/lib/cli.js.map +7 -0
  46. package/lib/config.cjs +30 -0
  47. package/lib/config.cjs.map +7 -0
  48. package/lib/config.js +10 -0
  49. package/lib/config.js.map +7 -0
  50. package/lib/constants.cjs +39 -0
  51. package/lib/constants.cjs.map +7 -0
  52. package/lib/constants.js +15 -0
  53. package/lib/constants.js.map +7 -0
  54. package/lib/denormalise.cjs +148 -0
  55. package/lib/denormalise.cjs.map +7 -0
  56. package/lib/denormalise.js +118 -0
  57. package/lib/denormalise.js.map +7 -0
  58. package/lib/dimensionToSVG.cjs +307 -0
  59. package/lib/dimensionToSVG.cjs.map +7 -0
  60. package/lib/dimensionToSVG.js +273 -0
  61. package/lib/dimensionToSVG.js.map +7 -0
  62. package/lib/entityToPolyline.cjs +248 -0
  63. package/lib/entityToPolyline.cjs.map +7 -0
  64. package/lib/entityToPolyline.js +213 -0
  65. package/lib/entityToPolyline.js.map +7 -0
  66. package/lib/getRGBForEntity.cjs +53 -0
  67. package/lib/getRGBForEntity.cjs.map +7 -0
  68. package/lib/getRGBForEntity.js +23 -0
  69. package/lib/getRGBForEntity.js.map +7 -0
  70. package/lib/groupEntitiesByLayer.cjs +34 -0
  71. package/lib/groupEntitiesByLayer.cjs.map +7 -0
  72. package/lib/groupEntitiesByLayer.js +14 -0
  73. package/lib/groupEntitiesByLayer.js.map +7 -0
  74. package/lib/handlers/blocks.cjs +93 -0
  75. package/lib/handlers/blocks.cjs.map +7 -0
  76. package/lib/handlers/blocks.js +63 -0
  77. package/lib/handlers/blocks.js.map +7 -0
  78. package/lib/handlers/entities.cjs +118 -0
  79. package/lib/handlers/entities.cjs.map +7 -0
  80. package/lib/handlers/entities.js +88 -0
  81. package/lib/handlers/entities.js.map +7 -0
  82. package/lib/handlers/entity/arc.cjs +82 -0
  83. package/lib/handlers/entity/arc.cjs.map +7 -0
  84. package/lib/handlers/entity/arc.js +47 -0
  85. package/lib/handlers/entity/arc.js.map +7 -0
  86. package/lib/handlers/entity/attdef.cjs +318 -0
  87. package/lib/handlers/entity/attdef.cjs.map +7 -0
  88. package/lib/handlers/entity/attdef.js +282 -0
  89. package/lib/handlers/entity/attdef.js.map +7 -0
  90. package/lib/handlers/entity/attrib.cjs +52 -0
  91. package/lib/handlers/entity/attrib.cjs.map +7 -0
  92. package/lib/handlers/entity/attrib.js +27 -0
  93. package/lib/handlers/entity/attrib.js.map +7 -0
  94. package/lib/handlers/entity/circle.cjs +73 -0
  95. package/lib/handlers/entity/circle.cjs.map +7 -0
  96. package/lib/handlers/entity/circle.js +38 -0
  97. package/lib/handlers/entity/circle.js.map +7 -0
  98. package/lib/handlers/entity/common.cjs +83 -0
  99. package/lib/handlers/entity/common.cjs.map +7 -0
  100. package/lib/handlers/entity/common.js +63 -0
  101. package/lib/handlers/entity/common.js.map +7 -0
  102. package/lib/handlers/entity/dimension.cjs +203 -0
  103. package/lib/handlers/entity/dimension.cjs.map +7 -0
  104. package/lib/handlers/entity/dimension.js +168 -0
  105. package/lib/handlers/entity/dimension.js.map +7 -0
  106. package/lib/handlers/entity/ellipse.cjs +88 -0
  107. package/lib/handlers/entity/ellipse.cjs.map +7 -0
  108. package/lib/handlers/entity/ellipse.js +53 -0
  109. package/lib/handlers/entity/ellipse.js.map +7 -0
  110. package/lib/handlers/entity/hatch.cjs +470 -0
  111. package/lib/handlers/entity/hatch.cjs.map +7 -0
  112. package/lib/handlers/entity/hatch.js +435 -0
  113. package/lib/handlers/entity/hatch.js.map +7 -0
  114. package/lib/handlers/entity/insert.cjs +106 -0
  115. package/lib/handlers/entity/insert.cjs.map +7 -0
  116. package/lib/handlers/entity/insert.js +71 -0
  117. package/lib/handlers/entity/insert.js.map +7 -0
  118. package/lib/handlers/entity/line.cjs +84 -0
  119. package/lib/handlers/entity/line.cjs.map +7 -0
  120. package/lib/handlers/entity/line.js +49 -0
  121. package/lib/handlers/entity/line.js.map +7 -0
  122. package/lib/handlers/entity/lwpolyline.cjs +82 -0
  123. package/lib/handlers/entity/lwpolyline.cjs.map +7 -0
  124. package/lib/handlers/entity/lwpolyline.js +47 -0
  125. package/lib/handlers/entity/lwpolyline.js.map +7 -0
  126. package/lib/handlers/entity/mtext.cjs +121 -0
  127. package/lib/handlers/entity/mtext.cjs.map +7 -0
  128. package/lib/handlers/entity/mtext.js +85 -0
  129. package/lib/handlers/entity/mtext.js.map +7 -0
  130. package/lib/handlers/entity/ole2Frame.cjs +98 -0
  131. package/lib/handlers/entity/ole2Frame.cjs.map +7 -0
  132. package/lib/handlers/entity/ole2Frame.js +63 -0
  133. package/lib/handlers/entity/ole2Frame.js.map +7 -0
  134. package/lib/handlers/entity/point.cjs +73 -0
  135. package/lib/handlers/entity/point.cjs.map +7 -0
  136. package/lib/handlers/entity/point.js +38 -0
  137. package/lib/handlers/entity/point.js.map +7 -0
  138. package/lib/handlers/entity/polyline.cjs +70 -0
  139. package/lib/handlers/entity/polyline.cjs.map +7 -0
  140. package/lib/handlers/entity/polyline.js +35 -0
  141. package/lib/handlers/entity/polyline.js.map +7 -0
  142. package/lib/handlers/entity/solid.cjs +101 -0
  143. package/lib/handlers/entity/solid.cjs.map +7 -0
  144. package/lib/handlers/entity/solid.js +66 -0
  145. package/lib/handlers/entity/solid.js.map +7 -0
  146. package/lib/handlers/entity/spline.cjs +109 -0
  147. package/lib/handlers/entity/spline.cjs.map +7 -0
  148. package/lib/handlers/entity/spline.js +74 -0
  149. package/lib/handlers/entity/spline.js.map +7 -0
  150. package/lib/handlers/entity/text.cjs +85 -0
  151. package/lib/handlers/entity/text.cjs.map +7 -0
  152. package/lib/handlers/entity/text.js +49 -0
  153. package/lib/handlers/entity/text.js.map +7 -0
  154. package/lib/handlers/entity/threeDFace.cjs +98 -0
  155. package/lib/handlers/entity/threeDFace.cjs.map +7 -0
  156. package/lib/handlers/entity/threeDFace.js +63 -0
  157. package/lib/handlers/entity/threeDFace.js.map +7 -0
  158. package/lib/handlers/entity/vertex.cjs +78 -0
  159. package/lib/handlers/entity/vertex.cjs.map +7 -0
  160. package/lib/handlers/entity/vertex.js +53 -0
  161. package/lib/handlers/entity/vertex.js.map +7 -0
  162. package/lib/handlers/entity/viewport.cjs +153 -0
  163. package/lib/handlers/entity/viewport.cjs.map +7 -0
  164. package/lib/handlers/entity/viewport.js +118 -0
  165. package/lib/handlers/entity/viewport.js.map +7 -0
  166. package/lib/handlers/header.cjs +92 -0
  167. package/lib/handlers/header.cjs.map +7 -0
  168. package/lib/handlers/header.js +72 -0
  169. package/lib/handlers/header.js.map +7 -0
  170. package/lib/handlers/objects.cjs +170 -0
  171. package/lib/handlers/objects.cjs.map +7 -0
  172. package/lib/handlers/objects.js +150 -0
  173. package/lib/handlers/objects.js.map +7 -0
  174. package/lib/handlers/tables.cjs +587 -0
  175. package/lib/handlers/tables.cjs.map +7 -0
  176. package/lib/handlers/tables.js +557 -0
  177. package/lib/handlers/tables.js.map +7 -0
  178. package/lib/index.cjs +60 -0
  179. package/lib/index.cjs.map +7 -0
  180. package/lib/index.js +19 -0
  181. package/lib/index.js.map +7 -0
  182. package/lib/parseString.cjs +118 -0
  183. package/lib/parseString.cjs.map +7 -0
  184. package/lib/parseString.js +88 -0
  185. package/lib/parseString.js.map +7 -0
  186. package/lib/toPolylines.cjs +69 -0
  187. package/lib/toPolylines.cjs.map +7 -0
  188. package/lib/toPolylines.js +39 -0
  189. package/lib/toPolylines.js.map +7 -0
  190. package/lib/toSVG.cjs +395 -0
  191. package/lib/toSVG.cjs.map +7 -0
  192. package/lib/toSVG.js +361 -0
  193. package/lib/toSVG.js.map +7 -0
  194. package/lib/types/arc-entity.cjs +17 -0
  195. package/lib/types/arc-entity.cjs.map +7 -0
  196. package/lib/types/arc-entity.js +1 -0
  197. package/lib/types/arc-entity.js.map +7 -0
  198. package/lib/types/base-entity.cjs +17 -0
  199. package/lib/types/base-entity.cjs.map +7 -0
  200. package/lib/types/base-entity.js +1 -0
  201. package/lib/types/base-entity.js.map +7 -0
  202. package/lib/types/circle-entity.cjs +17 -0
  203. package/lib/types/circle-entity.cjs.map +7 -0
  204. package/lib/types/circle-entity.js +1 -0
  205. package/lib/types/circle-entity.js.map +7 -0
  206. package/lib/types/common.cjs +17 -0
  207. package/lib/types/common.cjs.map +7 -0
  208. package/lib/types/common.js +1 -0
  209. package/lib/types/common.js.map +7 -0
  210. package/lib/types/dimension-entity.cjs +17 -0
  211. package/lib/types/dimension-entity.cjs.map +7 -0
  212. package/lib/types/dimension-entity.js +1 -0
  213. package/lib/types/dimension-entity.js.map +7 -0
  214. package/lib/types/dxf.cjs +17 -0
  215. package/lib/types/dxf.cjs.map +7 -0
  216. package/lib/types/dxf.js +1 -0
  217. package/lib/types/dxf.js.map +7 -0
  218. package/lib/types/ellipse-entity.cjs +17 -0
  219. package/lib/types/ellipse-entity.cjs.map +7 -0
  220. package/lib/types/ellipse-entity.js +1 -0
  221. package/lib/types/ellipse-entity.js.map +7 -0
  222. package/lib/types/entity.cjs +17 -0
  223. package/lib/types/entity.cjs.map +7 -0
  224. package/lib/types/entity.js +1 -0
  225. package/lib/types/entity.js.map +7 -0
  226. package/lib/types/handler-internal.cjs +17 -0
  227. package/lib/types/handler-internal.cjs.map +7 -0
  228. package/lib/types/handler-internal.js +1 -0
  229. package/lib/types/handler-internal.js.map +7 -0
  230. package/lib/types/handler.cjs +17 -0
  231. package/lib/types/handler.cjs.map +7 -0
  232. package/lib/types/handler.js +1 -0
  233. package/lib/types/handler.js.map +7 -0
  234. package/lib/types/hatch-entity.cjs +17 -0
  235. package/lib/types/hatch-entity.cjs.map +7 -0
  236. package/lib/types/hatch-entity.js +1 -0
  237. package/lib/types/hatch-entity.js.map +7 -0
  238. package/lib/types/helper.cjs +17 -0
  239. package/lib/types/helper.cjs.map +7 -0
  240. package/lib/types/helper.js +1 -0
  241. package/lib/types/helper.js.map +7 -0
  242. package/lib/types/index.cjs +77 -0
  243. package/lib/types/index.cjs.map +7 -0
  244. package/lib/types/index.js +29 -0
  245. package/lib/types/index.js.map +7 -0
  246. package/lib/types/insert-entity.cjs +17 -0
  247. package/lib/types/insert-entity.cjs.map +7 -0
  248. package/lib/types/insert-entity.js +1 -0
  249. package/lib/types/insert-entity.js.map +7 -0
  250. package/lib/types/layer-groups.cjs +17 -0
  251. package/lib/types/layer-groups.cjs.map +7 -0
  252. package/lib/types/layer-groups.js +1 -0
  253. package/lib/types/layer-groups.js.map +7 -0
  254. package/lib/types/line-entity.cjs +17 -0
  255. package/lib/types/line-entity.cjs.map +7 -0
  256. package/lib/types/line-entity.js +1 -0
  257. package/lib/types/line-entity.js.map +7 -0
  258. package/lib/types/mtext-entity.cjs +17 -0
  259. package/lib/types/mtext-entity.cjs.map +7 -0
  260. package/lib/types/mtext-entity.js +1 -0
  261. package/lib/types/mtext-entity.js.map +7 -0
  262. package/lib/types/ole2frame-entity.cjs +17 -0
  263. package/lib/types/ole2frame-entity.cjs.map +7 -0
  264. package/lib/types/ole2frame-entity.js +1 -0
  265. package/lib/types/ole2frame-entity.js.map +7 -0
  266. package/lib/types/options.cjs +17 -0
  267. package/lib/types/options.cjs.map +7 -0
  268. package/lib/types/options.js +1 -0
  269. package/lib/types/options.js.map +7 -0
  270. package/lib/types/point-entity.cjs +17 -0
  271. package/lib/types/point-entity.cjs.map +7 -0
  272. package/lib/types/point-entity.js +1 -0
  273. package/lib/types/point-entity.js.map +7 -0
  274. package/lib/types/polyline-entity.cjs +17 -0
  275. package/lib/types/polyline-entity.cjs.map +7 -0
  276. package/lib/types/polyline-entity.js +1 -0
  277. package/lib/types/polyline-entity.js.map +7 -0
  278. package/lib/types/polylines.cjs +17 -0
  279. package/lib/types/polylines.cjs.map +7 -0
  280. package/lib/types/polylines.js +1 -0
  281. package/lib/types/polylines.js.map +7 -0
  282. package/lib/types/solid-entity.cjs +17 -0
  283. package/lib/types/solid-entity.cjs.map +7 -0
  284. package/lib/types/solid-entity.js +1 -0
  285. package/lib/types/solid-entity.js.map +7 -0
  286. package/lib/types/spline-entity.cjs +17 -0
  287. package/lib/types/spline-entity.cjs.map +7 -0
  288. package/lib/types/spline-entity.js +1 -0
  289. package/lib/types/spline-entity.js.map +7 -0
  290. package/lib/types/svg.cjs +17 -0
  291. package/lib/types/svg.cjs.map +7 -0
  292. package/lib/types/svg.js +1 -0
  293. package/lib/types/svg.js.map +7 -0
  294. package/lib/types/tables.cjs +17 -0
  295. package/lib/types/tables.cjs.map +7 -0
  296. package/lib/types/tables.js +1 -0
  297. package/lib/types/tables.js.map +7 -0
  298. package/lib/types/text-entity.cjs +17 -0
  299. package/lib/types/text-entity.cjs.map +7 -0
  300. package/lib/types/text-entity.js +1 -0
  301. package/lib/types/text-entity.js.map +7 -0
  302. package/lib/types/util-types.cjs +17 -0
  303. package/lib/types/util-types.cjs.map +7 -0
  304. package/lib/types/util-types.js +1 -0
  305. package/lib/types/util-types.js.map +7 -0
  306. package/lib/types/vecks.d.cjs +2 -0
  307. package/lib/types/vecks.d.cjs.map +7 -0
  308. package/lib/types/vecks.d.js +1 -0
  309. package/lib/types/vecks.d.js.map +7 -0
  310. package/lib/types/viewport-entity.cjs +17 -0
  311. package/lib/types/viewport-entity.cjs.map +7 -0
  312. package/lib/types/viewport-entity.js +1 -0
  313. package/lib/types/viewport-entity.js.map +7 -0
  314. package/lib/types.cjs +23 -0
  315. package/lib/types.cjs.map +7 -0
  316. package/lib/types.js +2 -0
  317. package/lib/types.js.map +7 -0
  318. package/lib/util/bSpline.cjs +95 -0
  319. package/lib/util/bSpline.cjs.map +7 -0
  320. package/lib/util/bSpline.js +65 -0
  321. package/lib/util/bSpline.js.map +7 -0
  322. package/lib/util/colors.cjs +283 -0
  323. package/lib/util/colors.cjs.map +7 -0
  324. package/lib/util/colors.js +263 -0
  325. package/lib/util/colors.js.map +7 -0
  326. package/lib/util/createArcForLWPolyline.cjs +84 -0
  327. package/lib/util/createArcForLWPolyline.cjs.map +7 -0
  328. package/lib/util/createArcForLWPolyline.js +64 -0
  329. package/lib/util/createArcForLWPolyline.js.map +7 -0
  330. package/lib/util/dxfColorToRGB.cjs +115 -0
  331. package/lib/util/dxfColorToRGB.cjs.map +7 -0
  332. package/lib/util/dxfColorToRGB.js +90 -0
  333. package/lib/util/dxfColorToRGB.js.map +7 -0
  334. package/lib/util/insertKnot.cjs +77 -0
  335. package/lib/util/insertKnot.cjs.map +7 -0
  336. package/lib/util/insertKnot.js +57 -0
  337. package/lib/util/insertKnot.js.map +7 -0
  338. package/lib/util/logger.cjs +53 -0
  339. package/lib/util/logger.cjs.map +7 -0
  340. package/lib/util/logger.js +23 -0
  341. package/lib/util/logger.js.map +7 -0
  342. package/lib/util/rgbToColorAttribute.cjs +32 -0
  343. package/lib/util/rgbToColorAttribute.cjs.map +7 -0
  344. package/lib/util/rgbToColorAttribute.js +12 -0
  345. package/lib/util/rgbToColorAttribute.js.map +7 -0
  346. package/lib/util/rotate.cjs +30 -0
  347. package/lib/util/rotate.cjs.map +7 -0
  348. package/lib/util/rotate.js +10 -0
  349. package/lib/util/rotate.js.map +7 -0
  350. package/lib/util/round10.cjs +38 -0
  351. package/lib/util/round10.cjs.map +7 -0
  352. package/lib/util/round10.js +18 -0
  353. package/lib/util/round10.js.map +7 -0
  354. package/lib/util/toPiecewiseBezier.cjs +90 -0
  355. package/lib/util/toPiecewiseBezier.cjs.map +7 -0
  356. package/lib/util/toPiecewiseBezier.js +54 -0
  357. package/lib/util/toPiecewiseBezier.js.map +7 -0
  358. package/lib/util/transformBoundingBoxAndElement.cjs +80 -0
  359. package/lib/util/transformBoundingBoxAndElement.cjs.map +7 -0
  360. package/lib/util/transformBoundingBoxAndElement.js +60 -0
  361. package/lib/util/transformBoundingBoxAndElement.js.map +7 -0
  362. package/package.json +127 -0
  363. package/src/Helper.ts +71 -0
  364. package/src/applyTransforms.ts +54 -0
  365. package/src/cli.ts +41 -0
  366. package/src/config.ts +10 -0
  367. package/src/constants.ts +14 -0
  368. package/src/denormalise.ts +153 -0
  369. package/src/dimensionToSVG.ts +427 -0
  370. package/src/entityToPolyline.ts +338 -0
  371. package/src/getRGBForEntity.ts +28 -0
  372. package/src/groupEntitiesByLayer.ts +14 -0
  373. package/src/handlers/blocks.ts +65 -0
  374. package/src/handlers/entities.ts +111 -0
  375. package/src/handlers/entity/arc.ts +61 -0
  376. package/src/handlers/entity/attdef.ts +284 -0
  377. package/src/handlers/entity/attrib.ts +29 -0
  378. package/src/handlers/entity/circle.ts +47 -0
  379. package/src/handlers/entity/common.ts +79 -0
  380. package/src/handlers/entity/dimension.ts +217 -0
  381. package/src/handlers/entity/ellipse.ts +55 -0
  382. package/src/handlers/entity/hatch.ts +471 -0
  383. package/src/handlers/entity/insert.ts +73 -0
  384. package/src/handlers/entity/line.ts +56 -0
  385. package/src/handlers/entity/lwpolyline.ts +54 -0
  386. package/src/handlers/entity/mtext.ts +150 -0
  387. package/src/handlers/entity/ole2Frame.ts +64 -0
  388. package/src/handlers/entity/point.ts +47 -0
  389. package/src/handlers/entity/polyline.ts +49 -0
  390. package/src/handlers/entity/solid.ts +73 -0
  391. package/src/handlers/entity/spline.ts +103 -0
  392. package/src/handlers/entity/text.ts +83 -0
  393. package/src/handlers/entity/threeDFace.ts +69 -0
  394. package/src/handlers/entity/vertex.ts +55 -0
  395. package/src/handlers/entity/viewport.ts +119 -0
  396. package/src/handlers/header.ts +73 -0
  397. package/src/handlers/objects.ts +152 -0
  398. package/src/handlers/tables.ts +581 -0
  399. package/src/index.ts +19 -0
  400. package/src/parseString.ts +97 -0
  401. package/src/toPolylines.ts +47 -0
  402. package/src/toSVG.ts +518 -0
  403. package/src/types/README.md +91 -0
  404. package/src/types/arc-entity.ts +10 -0
  405. package/src/types/base-entity.ts +25 -0
  406. package/src/types/circle-entity.ts +8 -0
  407. package/src/types/common.ts +37 -0
  408. package/src/types/dimension-entity.ts +23 -0
  409. package/src/types/dxf.ts +64 -0
  410. package/src/types/ellipse-entity.ts +13 -0
  411. package/src/types/entity.ts +32 -0
  412. package/src/types/handler-internal.ts +51 -0
  413. package/src/types/handler.ts +10 -0
  414. package/src/types/hatch-entity.ts +127 -0
  415. package/src/types/helper.ts +12 -0
  416. package/src/types/index.ts +53 -0
  417. package/src/types/insert-entity.ts +19 -0
  418. package/src/types/layer-groups.ts +8 -0
  419. package/src/types/line-entity.ts +10 -0
  420. package/src/types/mtext-entity.ts +35 -0
  421. package/src/types/ole2frame-entity.ts +35 -0
  422. package/src/types/options.ts +17 -0
  423. package/src/types/point-entity.ts +7 -0
  424. package/src/types/polyline-entity.ts +20 -0
  425. package/src/types/polylines.ts +22 -0
  426. package/src/types/solid-entity.ts +9 -0
  427. package/src/types/spline-entity.ts +12 -0
  428. package/src/types/svg.ts +31 -0
  429. package/src/types/tables.ts +414 -0
  430. package/src/types/text-entity.ts +23 -0
  431. package/src/types/util-types.ts +27 -0
  432. package/src/types/vecks.d.ts +29 -0
  433. package/src/types/viewport-entity.ts +81 -0
  434. package/src/types.ts +5 -0
  435. package/src/util/bSpline.ts +97 -0
  436. package/src/util/colors.ts +266 -0
  437. package/src/util/createArcForLWPolyline.ts +93 -0
  438. package/src/util/diagram.png +0 -0
  439. package/src/util/dxfColorToRGB.ts +106 -0
  440. package/src/util/insertKnot.ts +69 -0
  441. package/src/util/logger.ts +23 -0
  442. package/src/util/rgbToColorAttribute.ts +14 -0
  443. package/src/util/rotate.ts +14 -0
  444. package/src/util/round10.ts +24 -0
  445. package/src/util/toPiecewiseBezier.ts +70 -0
  446. package/src/util/transformBoundingBoxAndElement.ts +74 -0
  447. package/tsconfig.json +34 -0
package/package.json ADDED
@@ -0,0 +1,127 @@
1
+ {
2
+ "name": "@linkiez/dxf-renew",
3
+ "version": "5.3.1",
4
+ "description": "DXF parser for node/browser",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "module": "lib/index.js",
8
+ "types": "lib/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "import": "./lib/index.js",
13
+ "require": "./lib/index.cjs"
14
+ }
15
+ },
16
+ "packageManager": "yarn@4.12.0",
17
+ "bin": {
18
+ "dxf-to-svg": "lib/cli.js"
19
+ },
20
+ "engines": {
21
+ "node": ">=8.9.0"
22
+ },
23
+ "scripts": {
24
+ "compile:ts": "tsc",
25
+ "compile": "node build.mjs",
26
+ "build": "npm run compile",
27
+ "watch": "tsc --watch",
28
+ "type-check": "tsc --noEmit",
29
+ "dist": "esbuild src/index.ts --bundle --platform=browser --format=iife --global-name=dxf --outfile=dist/dxf.js",
30
+ "lint": "eslint src",
31
+ "clean": "rimraf dist/ lib/",
32
+ "prepublishOnly": "npm run lint && npm run type-check && npm run test && npm run clean && npm run build && npm run dist",
33
+ "prettier": "prettier --write .",
34
+ "test": "npm run test:unit",
35
+ "test:functional": "cd test/functional && webpack-dev-server",
36
+ "test:unit": "mocha --require tsx --recursive test/unit/** --extensions .ts,.js",
37
+ "test:unit:watch": "npm run test:unit -- --watch",
38
+ "prepare": "husky",
39
+ "semantic-release": "semantic-release",
40
+ "commit": "git-cz"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git://github.com/skymakerolof/dxf.git"
45
+ },
46
+ "keywords": [
47
+ "DXF",
48
+ "Parser",
49
+ "SVG"
50
+ ],
51
+ "author": "Ben Nortier <ben@bjnortier.com>",
52
+ "license": "MIT",
53
+ "bugs": {
54
+ "url": "https://github.com/skymakerolof/dxf/issues"
55
+ },
56
+ "homepage": "https://github.com/skymakerolof/dxf",
57
+ "devDependencies": {
58
+ "@babel/core": "^7.28.5",
59
+ "@babel/eslint-parser": "^7.25.1",
60
+ "@babel/preset-react": "^7.28.5",
61
+ "@commitlint/cli": "^20.1.0",
62
+ "@commitlint/config-conventional": "^20.0.0",
63
+ "@semantic-release/changelog": "^6.0.3",
64
+ "@semantic-release/git": "^10.0.1",
65
+ "@semantic-release/github": "^12.0.2",
66
+ "@types/babel__core": "^7",
67
+ "@types/lodash": "^4.17.20",
68
+ "@types/node": "^24.10.1",
69
+ "@typescript-eslint/eslint-plugin": "^8.46.4",
70
+ "@typescript-eslint/parser": "^8.46.4",
71
+ "browserify": "^16.5.2",
72
+ "commitizen": "^4.3.1",
73
+ "cz-conventional-changelog": "^3.3.0",
74
+ "esbuild": "^0.27.0",
75
+ "eslint": "^8.57.0",
76
+ "eslint-config-prettier": "^8.10.0",
77
+ "eslint-config-standard": "^17.1.0",
78
+ "eslint-config-standard-react": "^13.0.0",
79
+ "eslint-plugin-import": "^2.29.1",
80
+ "eslint-plugin-n": "^16.6.2",
81
+ "eslint-plugin-promise": "^6.6.0",
82
+ "eslint-plugin-react": "^7.35.0",
83
+ "eslint-plugin-react-hooks": "^4.6.2",
84
+ "expect": "^29.7.0",
85
+ "husky": "^9.1.7",
86
+ "mocha": "^10.7.3",
87
+ "prettier": "^3.3.3",
88
+ "prop-types": "^15.8.1",
89
+ "raw-loader": "^4.0.2",
90
+ "react": "^16.14.0",
91
+ "react-dom": "^16.14.0",
92
+ "react-router-dom": "^5.3.4",
93
+ "rimraf": "^6.0.1",
94
+ "semantic-release": "^25.0.2",
95
+ "standard-version": "^9.5.0",
96
+ "ts-node": "^10.9.2",
97
+ "tsx": "^4.20.6",
98
+ "typescript": "^5.9.3",
99
+ "webpack": "^5.94.0",
100
+ "webpack-cli": "^5.1.4",
101
+ "webpack-dev-server": "^4.15.2",
102
+ "xml2js": "^0.6.2"
103
+ },
104
+ "dependencies": {
105
+ "commander": "^2.20.3",
106
+ "lodash": "^4.17.21",
107
+ "vecks": "^3.9.2"
108
+ },
109
+ "config": {
110
+ "commitizen": {
111
+ "path": "cz-conventional-changelog"
112
+ }
113
+ },
114
+ "standard": {
115
+ "globals": [
116
+ "describe",
117
+ "it",
118
+ "before",
119
+ "beforeEach",
120
+ "after"
121
+ ],
122
+ "ignore": [
123
+ "lib/",
124
+ "dist/"
125
+ ]
126
+ }
127
+ }
package/src/Helper.ts ADDED
@@ -0,0 +1,71 @@
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
+
8
+ import type { Entity, LayerGroups, ParsedDXF } from './types'
9
+
10
+ export default class Helper {
11
+ private readonly _contents: string
12
+ private _parsed: ParsedDXF | null
13
+ private _denormalised: Entity[] | null
14
+ private _groups: LayerGroups | null
15
+
16
+ constructor(contents: string) {
17
+ if (typeof contents !== 'string') {
18
+ throw new TypeError('Helper constructor expects a DXF string')
19
+ }
20
+ this._contents = contents
21
+ this._parsed = null
22
+ this._denormalised = null
23
+ this._groups = null
24
+ }
25
+
26
+ parse(): ParsedDXF {
27
+ this._parsed = parseString(this._contents)
28
+ logger.info('parsed:', this.parsed)
29
+ return this._parsed
30
+ }
31
+
32
+ get parsed(): ParsedDXF {
33
+ if (this._parsed === null) {
34
+ this.parse()
35
+ }
36
+ return this._parsed as ParsedDXF
37
+ }
38
+
39
+ denormalise(): Entity[] {
40
+ this._denormalised = denormalise(this.parsed)
41
+ logger.info('denormalised:', this._denormalised)
42
+ return this._denormalised
43
+ }
44
+
45
+ get denormalised(): Entity[] {
46
+ if (!this._denormalised) {
47
+ this.denormalise()
48
+ }
49
+ return this._denormalised as Entity[]
50
+ }
51
+
52
+ group(): LayerGroups {
53
+ this._groups = groupEntitiesByLayer(this.denormalised)
54
+ return this._groups
55
+ }
56
+
57
+ get groups(): LayerGroups {
58
+ if (!this._groups) {
59
+ this.group()
60
+ }
61
+ return this._groups as LayerGroups
62
+ }
63
+
64
+ toSVG(): string {
65
+ return toSVG(this.parsed)
66
+ }
67
+
68
+ toPolylines(): ReturnType<typeof toPolylines> {
69
+ return toPolylines(this.parsed)
70
+ }
71
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Apply the transforms to the polyline.
3
+ *
4
+ * @param polyline the polyline
5
+ * @param transforms the transforms array
6
+ * @returns the transformed polyline
7
+ */
8
+
9
+ import type { PointTuple, Transform } from './types'
10
+
11
+ type Point = PointTuple
12
+
13
+ export default function applyTransforms(
14
+ polyline: Point[],
15
+ transforms?: Transform[],
16
+ ): Point[] {
17
+ if (!transforms) {
18
+ return polyline
19
+ }
20
+
21
+ let result = polyline
22
+ for (const transform of transforms) {
23
+ result = result.map((p) => {
24
+ // Use a copy to avoid side effects
25
+ let p2: Point = [p[0], p[1]]
26
+ if (transform.scaleX) {
27
+ p2[0] = p2[0] * transform.scaleX
28
+ }
29
+ if (transform.scaleY) {
30
+ p2[1] = p2[1] * transform.scaleY
31
+ }
32
+ if (transform.rotation) {
33
+ const angle = (transform.rotation / 180) * Math.PI
34
+ p2 = [
35
+ p2[0] * Math.cos(angle) - p2[1] * Math.sin(angle),
36
+ p2[1] * Math.cos(angle) + p2[0] * Math.sin(angle),
37
+ ]
38
+ }
39
+ if (transform.x) {
40
+ p2[0] = p2[0] + transform.x
41
+ }
42
+ if (transform.y) {
43
+ p2[1] = p2[1] + transform.y
44
+ }
45
+ // Observed once in a sample DXF - some cad applications
46
+ // use negative extruxion Z for flipping
47
+ if (transform.extrusionZ === -1) {
48
+ p2[0] = -p2[0]
49
+ }
50
+ return p2
51
+ })
52
+ }
53
+ return result
54
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander'
3
+ import fs from 'node:fs'
4
+ import { createRequire } from 'node:module'
5
+
6
+ import { denormalise, groupEntitiesByLayer, parseString, toSVG } from './'
7
+
8
+ const require = createRequire(
9
+ typeof __filename === 'string' ? __filename : import.meta.url,
10
+ )
11
+ const { version } = require('../package.json')
12
+
13
+ const program = new Command()
14
+
15
+ program
16
+ .version(version)
17
+ .description('Converts a dxf file to a svg file.')
18
+ .arguments('<dxfFile> [svgFile]')
19
+ .option('-v --verbose', 'Verbose output')
20
+ .action((dxfFile: string, svgFile: string | undefined, options: { verbose?: boolean }) => {
21
+ const parsed = parseString(fs.readFileSync(dxfFile, 'utf-8'))
22
+
23
+ if (options.verbose) {
24
+ const groups = groupEntitiesByLayer(denormalise(parsed))
25
+ console.log('[layer : number of entities]')
26
+ for (const layer of Object.keys(groups)) {
27
+ console.log(`${layer} : ${groups[layer].length}`)
28
+ }
29
+ }
30
+
31
+ fs.writeFileSync(
32
+ svgFile || `${dxfFile.split('.').slice(0, -1).join('.')}.svg`,
33
+ toSVG(parsed),
34
+ 'utf-8',
35
+ )
36
+ })
37
+ .parse(process.argv)
38
+
39
+ if (!process.argv.slice(2).length) {
40
+ program.help()
41
+ }
package/src/config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { Config } from './types'
2
+
3
+ const config: Config = {
4
+ verbose: false,
5
+ interpolationsPerSplineSegment: 100,
6
+ layers: [],
7
+ }
8
+
9
+ export default config
10
+
@@ -0,0 +1,14 @@
1
+ import type { ZeroTransform } from './types'
2
+
3
+ export const ZERO_TRANSFORM: ZeroTransform = {
4
+ x: 0,
5
+ y: 0,
6
+ scaleX: 1,
7
+ scaleY: 1,
8
+ scaleZ: 1,
9
+ rotation: 0,
10
+ extrusionX: 0,
11
+ extrusionY: 0,
12
+ extrusionZ: 1,
13
+ }
14
+
@@ -0,0 +1,153 @@
1
+ import cloneDeep from 'lodash/cloneDeep'
2
+
3
+ import logger from './util/logger'
4
+
5
+ import type {
6
+ ArcEntity,
7
+ Block,
8
+ CircleEntity,
9
+ EllipseEntity,
10
+ Entity,
11
+ InsertEntity,
12
+ LineEntity,
13
+ ParsedDXF,
14
+ PolylineEntity,
15
+ SplineEntity,
16
+ Transform,
17
+ } from './types'
18
+
19
+ export default function denormalise(parseResult: ParsedDXF): Entity[] {
20
+ const blocksByName = parseResult.blocks.reduce(
21
+ (acc: { [name: string]: Block }, b: Block) => {
22
+ acc[b.name] = b
23
+ return acc
24
+ },
25
+ {},
26
+ )
27
+
28
+ const gatherEntities = (
29
+ entities: Entity[],
30
+ transforms: Transform[],
31
+ ): Entity[] => {
32
+ let current: Entity[] = []
33
+ for (const e of entities) {
34
+ if (e.type === 'INSERT') {
35
+ const insert = e as InsertEntity
36
+ const block = blocksByName[insert.block]
37
+ if (!block) {
38
+ logger.error('no block found for insert. block:', insert.block)
39
+ continue
40
+ }
41
+
42
+ const rowCount = insert.rowCount ?? 1
43
+ const columnCount = insert.columnCount ?? 1
44
+ const rowSpacing = insert.rowSpacing ?? 0
45
+ const columnSpacing = insert.columnSpacing ?? 0
46
+ const rotation = insert.rotation ?? 0
47
+
48
+ // It appears that the rectangular array is affected by rotation, but NOT by scale.
49
+ let rowVec: { x: number; y: number }
50
+ let colVec: { x: number; y: number }
51
+ if (rowCount > 1 || columnCount > 1) {
52
+ const cos = Math.cos((rotation * Math.PI) / 180)
53
+ const sin = Math.sin((rotation * Math.PI) / 180)
54
+ rowVec = { x: -sin * rowSpacing, y: cos * rowSpacing }
55
+ colVec = { x: cos * columnSpacing, y: sin * columnSpacing }
56
+ } else {
57
+ rowVec = { x: 0, y: 0 }
58
+ colVec = { x: 0, y: 0 }
59
+ }
60
+
61
+ // For rectangular arrays, add the block entities for each location in the array
62
+ for (let r = 0; r < rowCount; r++) {
63
+ for (let c = 0; c < columnCount; c++) {
64
+ // Adjust insert transform by row and column for rectangular arrays
65
+ const t: Transform = {
66
+ x: insert.x + rowVec.x * r + colVec.x * c,
67
+ y: insert.y + rowVec.y * r + colVec.y * c,
68
+ scaleX: insert.scaleX,
69
+ scaleY: insert.scaleY,
70
+ scaleZ: insert.scaleZ,
71
+ extrusionX: insert.extrusionX,
72
+ extrusionY: insert.extrusionY,
73
+ extrusionZ: insert.extrusionZ,
74
+ rotation: insert.rotation,
75
+ }
76
+ // Add the insert transform and recursively add entities
77
+ const transforms2 = transforms.slice(0)
78
+ transforms2.push(t)
79
+
80
+ // Use the insert layer
81
+ const blockEntities = block.entities.map((be: Entity) => {
82
+ const be2 = cloneDeep(be)
83
+ be2.layer = insert.layer
84
+ // https://github.com/bjnortier/dxf/issues/52
85
+ // See Issue 52. If we don't modify the
86
+ // entity coordinates here it creates an issue with the
87
+ // transformation matrices (which are only applied AFTER
88
+ // block insertion modifications has been applied).
89
+ switch (be2.type) {
90
+ case 'LINE': {
91
+ const line = be2 as LineEntity
92
+ line.start.x -= block.x
93
+ line.start.y -= block.y
94
+ line.end.x -= block.x
95
+ line.end.y -= block.y
96
+ break
97
+ }
98
+ case 'LWPOLYLINE':
99
+ case 'POLYLINE': {
100
+ const poly = be2 as PolylineEntity
101
+ for (const v of poly.vertices) {
102
+ if (v.x !== undefined) v.x -= block.x
103
+ if (v.y !== undefined) v.y -= block.y
104
+ }
105
+ break
106
+ }
107
+ case 'CIRCLE': {
108
+ const circle = be2 as CircleEntity
109
+ circle.x -= block.x
110
+ circle.y -= block.y
111
+ break
112
+ }
113
+ case 'ELLIPSE': {
114
+ const ellipse = be2 as EllipseEntity
115
+ ellipse.x -= block.x
116
+ ellipse.y -= block.y
117
+ break
118
+ }
119
+ case 'ARC': {
120
+ const arc = be2 as ArcEntity
121
+ arc.x -= block.x
122
+ arc.y -= block.y
123
+ break
124
+ }
125
+ case 'SPLINE': {
126
+ const spline = be2 as SplineEntity
127
+ for (const cp of spline.controlPoints) {
128
+ cp.x -= block.x
129
+ cp.y -= block.y
130
+ }
131
+ break
132
+ }
133
+ }
134
+ return be2
135
+ })
136
+ current = current.concat(gatherEntities(blockEntities, transforms2))
137
+ }
138
+ }
139
+ } else {
140
+ // Top-level entity. Clone and add the transforms
141
+ // The transforms are reversed so they occur in
142
+ // order of application - i.e. the transform of the
143
+ // top-level insert is applied last
144
+ const e2 = cloneDeep(e)
145
+ e2.transforms = transforms.slice().reverse()
146
+ current.push(e2)
147
+ }
148
+ }
149
+ return current
150
+ }
151
+
152
+ return gatherEntities(parseResult.entities, [])
153
+ }