@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/PLAN.md ADDED
@@ -0,0 +1,517 @@
1
+
2
+ # DXF Parser Migration Plan (AutoCAD 2024) + Full 2D Coverage
3
+
4
+ This document describes a phased plan to align this project’s DXF parsing behavior with the AutoCAD 2024 DXF reference and to reach “complete 2D” feature coverage.
5
+
6
+ ## Goals
7
+
8
+ - Parse AutoCAD 2024-era DXF files reliably and deterministically.
9
+ - Provide complete 2D coverage for geometry + annotation features typically found in 2D drawings.
10
+ - Keep backwards compatibility with existing API outputs (`parseString`, `toSVG`, `toPolylines`) where feasible.
11
+ - Grow test coverage using real DXF fixtures and regression tests.
12
+
13
+ ## Non-goals
14
+
15
+ - Full 3D solids/meshes rendering.
16
+ - Full ObjectARX/.NET API parity (this is a DXF parser, not a CAD kernel).
17
+ - Perfect fidelity for every proprietary/extension object (fallback behavior is acceptable).
18
+
19
+ ## References (Autodesk, AutoCAD 2024)
20
+
21
+ Primary reference used for scope/checklists: AutoCAD 2024 Developer and ObjectARX Help → **DXF Reference**.
22
+
23
+ - Root: <https://help.autodesk.com/view/OARX/2024/ENU/>
24
+ - DXF Format entry point (guid): <https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-235B22E0-A567-4CF6-92D3-38A2306D73F3>
25
+
26
+ ## “Sitemap” / Checklist Source (DXF Reference TOC)
27
+
28
+ This sitemap is derived from the Autodesk 2024 DXF Reference left navigation (expanded nodes).
29
+
30
+ ### DXF Format
31
+
32
+ - About the DXF Format (DXF)
33
+ - About DXF Formatting Conventions
34
+ - About Object and Entity Codes (DXF)
35
+ - Group Code Value Types Reference (DXF)
36
+ - DXF Group Codes in Numerical Order Reference
37
+
38
+ ### Header Section
39
+
40
+ - About the DXF HEADER Section
41
+ - HEADER Section Group Codes (DXF)
42
+
43
+ ### Classes Section
44
+
45
+ - About the DXF CLASSES Section
46
+ - CLASSES Section Group Codes (DXF)
47
+ - Default Class Values (DXF)
48
+
49
+ ### Tables Section
50
+
51
+ - About the DXF TABLES Section (DXF)
52
+ - About Symbol Table Group Codes (DXF)
53
+ - Common Symbol Table Group Codes (DXF)
54
+ - APPID (DXF)
55
+ - BLOCK_RECORD (DXF)
56
+ - DIMSTYLE (DXF)
57
+ - LAYER (DXF)
58
+ - LTYPE (DXF)
59
+ - STYLE (DXF)
60
+ - UCS (DXF)
61
+ - VIEW (DXF)
62
+ - VPORT (DXF)
63
+
64
+ ### Blocks Section
65
+
66
+ - About the DXF BLOCKS Section
67
+ - About BLOCKS Section Group Codes (DXF)
68
+ - BLOCK (DXF)
69
+ - ENDBLK (DXF)
70
+
71
+ ### Entities Section
72
+
73
+ Autodesk lists many entities (including 3D). For “complete 2D”, the critical subset includes:
74
+
75
+ - ARC, CIRCLE, LINE
76
+ - LWPOLYLINE, POLYLINE (+ VERTEX + SEQEND)
77
+ - ELLIPSE, SPLINE
78
+ - HATCH, SOLID, TRACE, REGION
79
+ - POINT
80
+ - TEXT, MTEXT
81
+ - DIMENSION, LEADER, MLEADER, TOLERANCE
82
+ - INSERT, ATTDEF, ATTRIB
83
+ - VIEWPORT
84
+ - IMAGE, UNDERLAY, WIPEOUT
85
+ - RAY, XLINE
86
+ - OLEFRAME, OLE2FRAME
87
+ - TABLE (entity)
88
+
89
+ ### Objects Section
90
+
91
+ For 2D workflows, the most commonly required objects include:
92
+
93
+ - DICTIONARY / DICTIONARYVAR
94
+ - XRECORD
95
+ - LAYOUT
96
+ - DIMASSOC
97
+ - IMAGEDEF / IMAGEDEF_REACTOR
98
+ - GROUP
99
+ - TABLESTYLE
100
+ - FIELD
101
+
102
+ ## Current State (Repository Snapshot)
103
+
104
+ This section is intentionally short; it highlights gaps relevant to the migration.
105
+
106
+ ### Entities
107
+
108
+ Entity parsers currently exist for (see `src/handlers/entities.ts` and `src/handlers/entity/*`):
109
+
110
+ - Implemented: ARC, ATTDEF, ATTRIB, CIRCLE, DIMENSION, ELLIPSE, HATCH, INSERT, LINE, LWPOLYLINE, MTEXT, OLE2FRAME, POINT, POLYLINE, SOLID, SPLINE, TEXT, 3DFACE, VERTEX, VIEWPORT.
111
+ - Missing (not exhaustive): IMAGE, LEADER, MLEADER, MLINE, OLEFRAME, RAY, REGION, SEQEND handling robustness, TRACE, UNDERLAY, WIPEOUT, XLINE, SHAPE, TABLE (entity), TOLERANCE.
112
+
113
+ ### Tables
114
+
115
+ `src/handlers/tables.ts` parses:
116
+
117
+ - Implemented: LAYER, LTYPE, STYLE, VPORT, DIMSTYLE.
118
+ - Missing from Autodesk TOC: APPID, BLOCK_RECORD, UCS, VIEW.
119
+
120
+ ### Objects
121
+
122
+ `src/handlers/objects.ts` currently parses:
123
+
124
+ - Implemented: LAYOUT (partial).
125
+ - Missing from Autodesk TOC subset above: DICTIONARY, XRECORD, DIMASSOC, IMAGEDEF (+ reactor), FIELD, TABLESTYLE, GROUP, etc.
126
+
127
+ ## Project Analysis (Code-Backed)
128
+
129
+ This section grounds the roadmap in the current implementation so the plan is executable as a sequence of small PRs.
130
+
131
+ ### Public API surface
132
+
133
+ Main exports are in `src/index.ts`:
134
+
135
+ - `parseString` (core parser)
136
+ - `denormalise` (INSERT expansion + transform stacking)
137
+ - `toPolylines` (rendering-friendly geometry output)
138
+ - `toSVG` (SVG renderer)
139
+
140
+ CLI entry point: `src/cli.ts` (built as `dxf-to-svg`).
141
+
142
+ ### Parsing pipeline
143
+
144
+ - `src/parseString.ts` splits input into tuples and sections, then routes sections to:
145
+ - `src/handlers/header.ts`
146
+ - `src/handlers/tables.ts`
147
+ - `src/handlers/blocks.ts`
148
+ - `src/handlers/entities.ts`
149
+ - `src/handlers/objects.ts`
150
+
151
+ ### Entity parsing coverage (file-backed)
152
+
153
+ Entity handlers are in `src/handlers/entity/*.ts` and registered in `src/handlers/entities.ts`.
154
+
155
+ **Currently parsed (ENTITIES section):**
156
+
157
+ - ARC (`src/handlers/entity/arc.ts`)
158
+ - ATTDEF (`src/handlers/entity/attdef.ts`)
159
+ - ATTRIB (`src/handlers/entity/attrib.ts`)
160
+ - CIRCLE (`src/handlers/entity/circle.ts`)
161
+ - DIMENSION (`src/handlers/entity/dimension.ts`)
162
+ - ELLIPSE (`src/handlers/entity/ellipse.ts`)
163
+ - HATCH (`src/handlers/entity/hatch.ts`)
164
+ - INSERT (`src/handlers/entity/insert.ts`)
165
+ - LINE (`src/handlers/entity/line.ts`)
166
+ - LWPOLYLINE (`src/handlers/entity/lwpolyline.ts`)
167
+ - MTEXT (`src/handlers/entity/mtext.ts`)
168
+ - OLE2FRAME (`src/handlers/entity/ole2Frame.ts`)
169
+ - POINT (`src/handlers/entity/point.ts`)
170
+ - POLYLINE (`src/handlers/entity/polyline.ts`)
171
+ - SOLID (`src/handlers/entity/solid.ts`)
172
+ - SPLINE (`src/handlers/entity/spline.ts`)
173
+ - TEXT (`src/handlers/entity/text.ts`)
174
+ - 3DFACE (`src/handlers/entity/threeDFace.ts`)
175
+ - VERTEX (`src/handlers/entity/vertex.ts`)
176
+ - VIEWPORT (`src/handlers/entity/viewport.ts`)
177
+
178
+ **Special case (no dedicated handler file yet):**
179
+
180
+ - `SEQEND` is used as a sentinel in `src/handlers/entities.ts` to terminate a running `POLYLINE`.
181
+
182
+ ### Rendering coverage matrix (what is parsed vs what is renderable)
183
+
184
+ The project has two rendering outputs:
185
+
186
+ - `toPolylines` → depends on `src/entityToPolyline.ts`
187
+ - `toSVG` → depends on `src/toSVG.ts` (native SVG for arc/circle/ellipse + polyline approximations)
188
+
189
+ | Entity type | Parsed | Block INSERT basepoint handled in `denormalise` | `toPolylines` support | `toSVG` support |
190
+ | --- | --- | --- | --- | --- |
191
+ | LINE | Yes | Yes | Yes | Yes |
192
+ | LWPOLYLINE | Yes | Yes | Yes | Yes |
193
+ | POLYLINE | Yes | Yes | Yes | Yes |
194
+ | VERTEX | Yes | N/A | N/A | N/A |
195
+ | SEQEND | Sentinel only | N/A | N/A | N/A |
196
+ | ARC | Yes | Yes | Yes | Yes |
197
+ | CIRCLE | Yes | Yes | Yes | Yes |
198
+ | ELLIPSE | Yes | Yes | Yes | Yes |
199
+ | SPLINE | Yes | Yes (control points) | Yes | Yes (Bezier when possible) |
200
+ | TEXT | Yes | No | No | Yes |
201
+ | MTEXT | Yes | No | No | Yes |
202
+ | DIMENSION | Yes | No | No | Yes |
203
+ | INSERT | Yes | Yes (expands blocks) | Indirect (via expanded entities) | Indirect (via expanded entities) |
204
+ | HATCH | Yes | No | No | No |
205
+ | SOLID | Yes | No | No | No |
206
+ | POINT | Yes | No | No | No |
207
+ | VIEWPORT | Yes | No | No | No |
208
+ | OLE2FRAME | Yes | No | No | No |
209
+ | 3DFACE | Yes | No | No | No |
210
+
211
+ **Key implication:** adding “complete 2D” is not only about parsing more entity types; it requires expanding rendering support in `src/toSVG.ts` and `src/entityToPolyline.ts` and ensuring `src/denormalise.ts` adjusts block-contained entities consistently.
212
+
213
+ ### TABLES coverage (code-backed)
214
+
215
+ `src/handlers/tables.ts` currently extracts only: `LAYER`, `LTYPE`, `STYLE`, `VPORT`, `DIMSTYLE`.
216
+
217
+ Autodesk 2024 TOC includes additional tables relevant to 2D interoperability: `APPID`, `BLOCK_RECORD`, `UCS`, `VIEW`.
218
+
219
+ ### OBJECTS coverage (code-backed)
220
+
221
+ `src/handlers/objects.ts` currently extracts only `LAYOUT` objects into `objects.layouts`.
222
+
223
+ For 2D annotation + external references, real-world DXFs frequently require at least: `DICTIONARY`, `XRECORD`, `DIMASSOC`, and image/underlay definitions.
224
+
225
+ ### Test suite reality check
226
+
227
+ There is already substantial fixture coverage in `test/resources/*.dxf` and unit coverage in `test/unit/*.test.js`.
228
+
229
+ - Rendering tests exist for `toSVG`, `toPolylines`, dimension/text, blocks/inserts, and hatches.
230
+ - Use this existing corpus to gate each milestone; add only minimal new fixtures per newly-supported feature.
231
+
232
+ ## Milestones
233
+
234
+ ### M0 — Baseline & Regression Harness
235
+
236
+ **Goal:** prevent regressions while expanding coverage.
237
+
238
+ **Primary files:** `test/unit/*`, `test/resources/*`, `src/toSVG.ts`, `src/toPolylines.ts`, `src/parseString.ts`.
239
+
240
+ **PR-sized breakdown:**
241
+
242
+ - PR 0.1: Add/confirm one “golden” unit test per public API (`parseString`, `toPolylines`, `toSVG`).
243
+ - PR 0.2: Add a test-only strict mode helper (e.g., fail on unknown entity/table/object types) without changing the runtime default behavior.
244
+ - PR 0.3: Add 1–3 new fixtures only if existing fixtures don’t cover a targeted feature.
245
+
246
+ - Add/confirm a single “golden” pipeline test per API surface:
247
+ - `parseString()` parses representative DXFs without throwing.
248
+ - `toPolylines()` returns stable polyline counts and bounding boxes.
249
+ - `toSVG()` returns stable SVG output for representative fixtures.
250
+ - Add a “strict mode” test option (only for tests) to fail on unknown entity/table/object types.
251
+ - Add fixtures that represent real 2D drawings (architectural plan, dimensions/text-heavy, blocks+attributes, hatches).
252
+
253
+ **Acceptance criteria:** CI tests cover at least 1 DXF per major feature: lines/polylines, arcs/circles, text/mtext, dimensions, blocks/inserts, hatch.
254
+
255
+ ### M1 — DXF Format & Section-Level Compliance
256
+
257
+ **Goal:** make the parser robust to AutoCAD 2024 output patterns.
258
+
259
+ **Primary files:** `src/parseString.ts`, `src/handlers/header.ts`, `src/types/tables.ts`, `src/types/dxf.ts`.
260
+
261
+ **PR-sized breakdown:**
262
+
263
+ - PR 1.1: Expand `HEADER` parsing from a small whitelist to (a) a known-keys map + (b) an `unknownHeader` map for forward compatibility.
264
+ - PR 1.2: Harden section separation/reduction so malformed DXFs do not crash (keep warning logs, but continue parsing).
265
+ - PR 1.3: Add targeted fixtures that exercise AutoCAD-exported headers and validate typing.
266
+
267
+ - Normalize group code parsing (string vs number vs float) based on “Group Code Value Types Reference”.
268
+ - Harden section parsing:
269
+ - Detect and handle missing/extra section markers gracefully.
270
+ - Preserve unknown sections for debugging (optional), but ignore safely.
271
+ - Expand `HEADER` parsing to a structured map with correct typing.
272
+ - Expand `CLASSES` parsing to keep compatibility (even if not used downstream).
273
+
274
+ **Acceptance criteria:** no crash on DXF 2012–2024 fixtures; sections are parsed deterministically (same input → same output).
275
+
276
+ ### M2 — TABLES Coverage (2D-Relevant)
277
+
278
+ **Goal:** implement the table types required for consistent 2D rendering.
279
+
280
+ **Primary files:** `src/handlers/tables.ts`, `src/types/tables.ts`, `src/parseString.ts`, `test/unit/tables.test.js`.
281
+
282
+ **PR-sized breakdown:**
283
+
284
+ - PR 2.1: Add types for `APPID`, `BLOCK_RECORD`, `UCS`, `VIEW` entries (keep them minimal at first).
285
+ - PR 2.2: Extend `parseTables` to extract these table groups and return them on `parsed.tables`.
286
+ - PR 2.3: Add tests asserting the new table maps exist and contain expected keys for at least one fixture.
287
+
288
+ - Add parsers for: APPID, BLOCK_RECORD, UCS, VIEW.
289
+ - Validate that entity references to table entries resolve safely:
290
+ - Unknown handles/names should not crash; default fallbacks should apply.
291
+ - Ensure DIMSTYLE values used by `dimensionToSVG` are sourced from TABLES where possible.
292
+
293
+ **Acceptance criteria:** parsing DXFs with multiple dimstyles/linetypes/layers yields correct table maps and does not drop entries silently.
294
+
295
+ ### M3 — OBJECTS Coverage (2D-Relevant)
296
+
297
+ **Goal:** implement core objects used by 2D drawings and annotation.
298
+
299
+ **Primary files:** `src/handlers/objects.ts`, `src/types/tables.ts` (or a dedicated objects types file), `src/parseString.ts`.
300
+
301
+ **PR-sized breakdown:**
302
+
303
+ - PR 3.1: Add a minimal “object router” in `parseObjects` (similar to entities) that groups objects by `0` and dispatches by object type.
304
+ - PR 3.2: Implement `DICTIONARY` and `XRECORD` first (these unlock extensibility and metadata).
305
+ - PR 3.3: Implement `DIMASSOC` next (ties dimensions to geometry; should not crash if unresolved).
306
+ - PR 3.4: Implement image/underlay definitions (`IMAGEDEF`, reactors) to avoid hard failures on referenced resources.
307
+
308
+ - Add DICTIONARY/DICTIONARYVAR + XRECORD (often needed for extensibility and metadata).
309
+ - Add DIMASSOC and minimal FIELD support (enough to not crash and to extract useful text).
310
+ - Add IMAGEDEF/IMAGEDEF_REACTOR + UNDERLAY definitions for reference resolution.
311
+ - Extend LAYOUT parsing to cover paper/model space expectations.
312
+
313
+ **Acceptance criteria:** DXFs containing the above objects parse without warnings that indicate dropped essential data; references (handles) resolve when present.
314
+
315
+ ### M4 — ENTITIES: Complete 2D Set
316
+
317
+ **Goal:** implement missing 2D entities and make existing ones complete.
318
+
319
+ **Primary files:** `src/handlers/entities.ts`, `src/handlers/entity/*`, `src/types/*`, `src/denormalise.ts`.
320
+
321
+ **PR-sized breakdown (recommended order):**
322
+
323
+ - PR 4.1: Make `SEQEND` handling robust (ensure it terminates a polyline even if the `SEQEND` group is otherwise unsupported).
324
+ - PR 4.2: Add the first new 2D entity end-to-end: type + handler + at least one fixture/test + minimal rendering support.
325
+ - PR 4.3+: Continue entity additions in small vertical slices (one entity or one closely-related group per PR).
326
+
327
+ 1. Fix polyline sequencing robustness
328
+
329
+ Ensure `SEQEND` ends a running `POLYLINE` even if `SEQEND` itself is not fully parsed. Ensure orphan `VERTEX` entities do not poison subsequent entities.
330
+
331
+ 1. Implement missing entity handlers (prioritized)
332
+
333
+ Annotation: LEADER, MLEADER, TOLERANCE. Geometry: REGION, TRACE. Reference: IMAGE, UNDERLAY, WIPEOUT. Construction: RAY, XLINE. Legacy: OLEFRAME. Table-in-entities: TABLE (entity). Optional/edge: SHAPE, MLINE.
334
+
335
+ 1. Ensure common fields are handled consistently
336
+
337
+ Layer, color, lineweight, linetype, extrusion/normal where applicable. Block/insert transforms applied consistently (`applyTransforms.ts`).
338
+
339
+ **Acceptance criteria:**
340
+
341
+ - Each targeted entity has:
342
+ - A type definition in `src/types/*`.
343
+ - A parser in `src/handlers/entity/*`.
344
+ - At least one fixture or unit test proving it parses and exports (toSVG or toPolylines).
345
+
346
+ ### M5 — Rendering Parity (toPolylines / toSVG)
347
+
348
+ **Goal:** ensure new parsing coverage is usable.
349
+
350
+ **Primary files:** `src/toSVG.ts`, `src/toPolylines.ts`, `src/entityToPolyline.ts`, `src/denormalise.ts`.
351
+
352
+ **PR-sized breakdown:**
353
+
354
+ - PR 5.1: Extend `entityToPolyline` to cover the next most common geometry beyond lines/arcs (e.g., SOLID, POINT, TRACE/REGION approximations as appropriate).
355
+ - PR 5.2: Extend `toSVG` entity switch to render the newly-supported entities (even as approximations).
356
+ - PR 5.3: Fix block insertion basepoint adjustments in `denormalise` so block-contained TEXT/MTEXT/DIMENSION (and other supported types) render in the right place.
357
+
358
+ - Extend `toPolylines()` to support newly-added entities, with reasonable approximations where needed.
359
+ - Extend `toSVG()` and `dimensionToSVG` to cover missing annotation entities.
360
+ - Ensure all transforms and bounds computation are correct.
361
+
362
+ **Acceptance criteria:** representative DXFs render without missing/empty output for supported features.
363
+
364
+ ### M6 — Docs, Versioning, and Compatibility
365
+
366
+ **Goal:** ship safely.
367
+
368
+ - Update docs to reflect AutoCAD 2024 reference (link + scope).
369
+ - Maintain backwards compatibility (or document breaking changes explicitly).
370
+ - Add a “Supported DXF features” matrix that is kept in sync with tests.
371
+
372
+ ## Definition of “Complete 2D” for This Project
373
+
374
+ The project is considered “complete 2D” when:
375
+
376
+ - All 2D-critical entities listed in the Entities checklist are parsed without crashing.
377
+ - `toPolylines` supports geometry entities used in 2D drawings (line/arc/circle/polylines/splines/ellipse/hatch/solid/trace/region) with usable approximation.
378
+ - `toSVG` supports annotations commonly required for drawings (text/mtext/dimensions/leaders) and blocks/inserts.
379
+ - TABLES and OBJECTS required for the above features are parsed sufficiently to resolve styles, layers, and references.
380
+
381
+ ## Appendix A — Supported DXF Features Matrix (2D)
382
+
383
+ This appendix turns the roadmap into a checklist that can be executed as small PRs.
384
+
385
+ Legend:
386
+
387
+ - **Parse**: DXF tuples → typed entity/table/object
388
+ - **Render (SVG)**: `src/toSVG.ts` produces output
389
+ - **Render (Polylines)**: `src/entityToPolyline.ts` + `src/toPolylines.ts` produce vertices
390
+ - **Block-safe**: `src/denormalise.ts` adjusts block basepoint for block-contained entities of this type
391
+
392
+ ### A.1 Entities (2D-critical)
393
+
394
+ Already parsed (handlers exist): LINE, LWPOLYLINE, POLYLINE, ARC, CIRCLE, ELLIPSE, SPLINE, TEXT, MTEXT, DIMENSION, INSERT, ATTDEF, ATTRIB, HATCH, SOLID, POINT, VIEWPORT, OLE2FRAME.
395
+
396
+ The items below are the main gaps to reach “complete 2D” as defined in this plan.
397
+
398
+ | Entity | Parse | Render (SVG) | Render (Polylines) | Block-safe | Minimal implementation checklist |
399
+ | --- | --- | --- | --- | --- | --- |
400
+ | SEQEND | Sentinel only | N/A | N/A | N/A | Add `src/handlers/entity/seqend.ts` (optional) or harden sequencing in `src/handlers/entities.ts` + add fixture that stresses POLYLINE/VERTEX/SEQEND ordering |
401
+ | LEADER | No | No | No | No | Add `src/types/leader-entity.ts` + export in `src/types/index.ts`; add `src/handlers/entity/leader.ts`; add `toSVG` case (even minimal); add fixture + unit test |
402
+ | MLEADER | No | No | No | No | Add `src/types/mleader-entity.ts`; add `src/handlers/entity/mleader.ts`; likely requires OBJECTS support (DICTIONARY/XRECORD) for full fidelity; start with parse-only + safe ignore in render |
403
+ | TOLERANCE | No | No | No | No | Add `src/types/tolerance-entity.ts`; add `src/handlers/entity/tolerance.ts`; render as text fallback (SVG only) |
404
+ | IMAGE | No | No | No | No | Add `src/types/image-entity.ts`; add `src/handlers/entity/image.ts`; add OBJECTS: IMAGEDEF/IMAGEDEF_REACTOR; render as placeholder rect or ignore safely |
405
+ | UNDERLAY | No | No | No | No | Add `src/types/underlay-entity.ts`; add `src/handlers/entity/underlay.ts`; add OBJECTS underlay defs; render placeholder/ignore |
406
+ | WIPEOUT | No | No | No | No | Add `src/types/wipeout-entity.ts`; add `src/handlers/entity/wipeout.ts`; render as polygon mask approximation or ignore safely |
407
+ | RAY | No | No | No | No | Add `src/types/ray-entity.ts`; add `src/handlers/entity/ray.ts`; render as long line (bounded by extents) or ignore |
408
+ | XLINE | No | No | No | No | Add `src/types/xline-entity.ts`; add `src/handlers/entity/xline.ts`; render as long line (bounded by extents) or ignore |
409
+ | OLEFRAME | No | No | No | No | Add `src/types/oleframe-entity.ts`; add `src/handlers/entity/oleframe.ts`; render placeholder/ignore |
410
+ | TRACE | No | No | No | No | Add `src/types/trace-entity.ts`; add `src/handlers/entity/trace.ts`; render as closed polyline (both SVG and polylines) |
411
+ | REGION | No | No | No | No | Add `src/types/region-entity.ts`; add `src/handlers/entity/region.ts`; start with parse-only + safe ignore in render |
412
+ | TABLE (entity) | No | No | No | No | Add `src/types/table-entity.ts`; add `src/handlers/entity/table.ts`; render minimal (text grid) or ignore safely |
413
+ | SHAPE | No | No | No | No | Add `src/types/shape-entity.ts`; add `src/handlers/entity/shape.ts`; likely depends on STYLE/LTYPE; start parse-only |
414
+ | MLINE | No | No | No | No | Add `src/types/mline-entity.ts`; add `src/handlers/entity/mline.ts`; likely depends on MLSTYLE object/table; start parse-only |
415
+
416
+ ### A.2 Tables (2D-relevant)
417
+
418
+ | Table | Current status | Primary file(s) to change | Minimal checklist |
419
+ | --- | --- | --- | --- |
420
+ | APPID | Missing | `src/handlers/tables.ts`, `src/types/tables.ts` | Add entry type; extract group in `parseTables`; add unit test verifying at least one APPID entry exists |
421
+ | BLOCK_RECORD | Missing | `src/handlers/tables.ts`, `src/types/tables.ts` | Add entry type; extract group in `parseTables`; ensure blocks can reference it without crashing |
422
+ | UCS | Missing | `src/handlers/tables.ts`, `src/types/tables.ts` | Add entry type (minimal fields); extract group in `parseTables`; add unit test |
423
+ | VIEW | Missing | `src/handlers/tables.ts`, `src/types/tables.ts` | Add entry type; extract group in `parseTables`; add unit test |
424
+
425
+ ### A.3 Objects (2D-relevant)
426
+
427
+ | Object | Current status | Primary file(s) to change | Minimal checklist |
428
+ | --- | --- | --- | --- |
429
+ | DICTIONARY | Missing | `src/handlers/objects.ts` (+ new types file if desired) | Group objects by `0`; add DICTIONARY parser; store by handle for lookup |
430
+ | XRECORD | Missing | `src/handlers/objects.ts` | Add XRECORD parser; preserve raw records for downstream consumers |
431
+ | DIMASSOC | Missing | `src/handlers/objects.ts` | Add DIMASSOC parse with safe unresolved references; add fixture-based test |
432
+ | IMAGEDEF / IMAGEDEF_REACTOR | Missing | `src/handlers/objects.ts` | Parse enough to resolve IMAGE entity references; do not crash if external files missing |
433
+ | FIELD | Missing | `src/handlers/objects.ts` | Parse as raw text/value pairs; do not attempt full evaluation initially |
434
+ | TABLESTYLE | Missing | `src/handlers/objects.ts` | Parse style basics; used later for TABLE entity rendering |
435
+ | GROUP | Missing | `src/handlers/objects.ts` | Parse group membership; safe ignore if not used |
436
+
437
+ ## Appendix B — PR Sequencing (Executable Roadmap)
438
+
439
+ This appendix provides an explicit sequence of PRs. The intent is to keep each PR small, testable, and shippable.
440
+
441
+ ### B.0 PR rules of thumb
442
+
443
+ - Prefer “vertical slices”: **type → handler → registration → tests → minimal rendering**.
444
+ - Keep “parse-only + safe ignore in render” as an acceptable intermediate state for complex entities.
445
+ - Each PR should add or update at least one unit test under `test/unit/*` and reuse an existing fixture in `test/resources/*` when possible.
446
+ - If a feature requires both ENTITIES and OBJECTS/TABLES, land the dependency first (OBJECTS/TABLES), then the entity.
447
+
448
+ ### B.1 Recommended order (high value first)
449
+
450
+ - **Stabilize existing behavior**: PR B1.1 (POLYLINE/VERTEX/SEQEND sequencing), PR B1.2 (block basepoint for TEXT/MTEXT/DIMENSION).
451
+ - **Unblock references and metadata**: PR B1.3 (OBJECTS dispatch + DICTIONARY), PR B1.4 (XRECORD).
452
+ - **Enable images/underlays**: PR B1.5 (IMAGEDEF / IMAGEDEF_REACTOR), PR B1.6 (IMAGE entity), PR B1.7 (UNDERLAY defs + UNDERLAY entity).
453
+ - **Add remaining common 2D annotation**: PR B1.8 (LEADER), PR B1.9 (TOLERANCE), PR B1.10 (DIMASSOC), PR B1.11 (MLEADER).
454
+
455
+ ### B.2 PR templates by feature type
456
+
457
+ #### B.2.1 New entity (simple geometry)
458
+
459
+ Use this template for entities like RAY/XLINE/TRACE.
460
+
461
+ - PR: Add `src/types/<name>-entity.ts` and export it from `src/types/index.ts`.
462
+ - PR: Add `src/handlers/entity/<name>.ts` and register in `src/handlers/entities.ts`.
463
+ - PR: Add minimal rendering (SVG: add a `case` in `src/toSVG.ts`; polylines: add a branch in `src/entityToPolyline.ts` if applicable).
464
+ - PR: Add/extend one fixture-based test (`test/unit/*`) proving parse + render does not crash.
465
+
466
+ #### B.2.2 New entity (reference-based)
467
+
468
+ Use this template for IMAGE/UNDERLAY/WIPEOUT.
469
+
470
+ - PR: Add/extend required OBJECTS first (e.g., IMAGEDEF).
471
+ - PR: Add entity parsing (store handles/refs).
472
+ - PR: Add rendering behavior as a placeholder element (preferred) or safe ignore with a warning (acceptable initially).
473
+ - PR: Add unit tests that assert parsing does not throw and that rendering behavior matches the chosen strategy.
474
+
475
+ #### B.2.3 New object (OBJECTS section)
476
+
477
+ - PR: Introduce object grouping + dispatch-by-type in `src/handlers/objects.ts`.
478
+ - PR: Implement one object type at a time (DICTIONARY, then XRECORD, then DIMASSOC, etc.).
479
+ - PR: Add tests using an existing fixture that contains the object, or add a minimal new fixture.
480
+
481
+ ### B.3 Concrete PR checklist per missing 2D entity
482
+
483
+ This table expands Appendix A into explicit PR steps.
484
+
485
+ | Entity | PR 1 (Parse) | PR 2 (SVG) | PR 3 (Polylines) | PR 4 (Block-safe) |
486
+ | --- | --- | --- | --- | --- |
487
+ | LEADER | Add type + handler + register + tests | Add minimal `toSVG` case | Optional (usually not needed) | Update `denormalise` if leader can appear in blocks |
488
+ | MLEADER | Add type + handler + register + tests (parse-only) | Safe ignore or placeholder first | N/A | Later, after DICTIONARY/XRECORD/DIMASSOC coverage |
489
+ | TOLERANCE | Add type + handler + register + tests | Render as text fallback | N/A | Update `denormalise` if used in blocks |
490
+ | IMAGE | Add IMAGEDEF(+reactor) objects, then IMAGE entity parse + tests | Placeholder rect/image element or safe ignore | N/A | Update `denormalise` for block-contained images |
491
+ | UNDERLAY | Add underlay defs objects, then UNDERLAY entity parse + tests | Placeholder | N/A | Optional |
492
+ | WIPEOUT | Add type + handler + tests (parse-only) | Placeholder or safe ignore | Optional (as polygon) | Optional |
493
+ | RAY | Add type + handler + tests | Render as bounded line | Optional | Optional |
494
+ | XLINE | Add type + handler + tests | Render as bounded line | Optional | Optional |
495
+ | OLEFRAME | Add type + handler + tests | Placeholder or safe ignore | N/A | Optional |
496
+ | TRACE | Add type + handler + tests | Render as closed polyline | Add polyline conversion | Optional |
497
+ | REGION | Add type + handler + tests (parse-only) | Safe ignore first | Safe ignore | N/A |
498
+ | TABLE (entity) | Add type + handler + tests (parse-only) | Safe ignore/placeholder | N/A | Optional |
499
+ | SHAPE | Add type + handler + tests (parse-only) | Safe ignore first | N/A | N/A |
500
+ | MLINE | Add type + handler + tests (parse-only) | Safe ignore first | N/A | N/A |
501
+
502
+ ### B.4 Concrete PR checklist for missing tables
503
+
504
+ - PR: Add types to `src/types/tables.ts` for APPID/BLOCK_RECORD/UCS/VIEW.
505
+ - PR: Extend `src/handlers/tables.ts` to extract the table groups and return them on `parsed.tables`.
506
+ - PR: Add tests in `test/unit/tables.test.js` asserting at least one entry is parsed for each newly-supported table in at least one fixture.
507
+
508
+ ### B.5 Concrete PR checklist for missing objects
509
+
510
+ - PR: Refactor `src/handlers/objects.ts` into group-by-object + dispatch-by-type (no behavior change for LAYOUT).
511
+ - PR: Add DICTIONARY support + tests.
512
+ - PR: Add XRECORD support + tests.
513
+ - PR: Add DIMASSOC support + tests.
514
+ - PR: Add IMAGEDEF / IMAGEDEF_REACTOR support + tests.
515
+ - PR: Add FIELD support + tests.
516
+ - PR: Add TABLESTYLE support + tests.
517
+ - PR: Add GROUP support + tests.