ducjs 2.4.0 → 3.0.3

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 (526) hide show
  1. package/README.md +4 -5
  2. package/dist/enums.d.ts +135 -0
  3. package/dist/enums.js +155 -0
  4. package/dist/index.d.ts +4 -1
  5. package/dist/index.js +4 -1
  6. package/dist/lazy-files.d.ts +31 -71
  7. package/dist/lazy-files.js +91 -163
  8. package/dist/parse.d.ts +16 -82
  9. package/dist/parse.js +56 -1646
  10. package/dist/restore/index.d.ts +0 -1
  11. package/dist/restore/index.js +0 -1
  12. package/dist/restore/restoreDataState.d.ts +6 -10
  13. package/dist/restore/restoreDataState.js +126 -128
  14. package/dist/restore/restoreElements.d.ts +1 -1
  15. package/dist/restore/restoreElements.js +31 -499
  16. package/dist/serialize.d.ts +11 -4
  17. package/dist/serialize.js +58 -2546
  18. package/dist/technical/index.d.ts +0 -1
  19. package/dist/technical/index.js +0 -1
  20. package/dist/technical/scopes.d.ts +2 -2
  21. package/dist/technical/scopes.js +29 -14
  22. package/dist/transform.d.ts +12 -0
  23. package/dist/transform.js +442 -0
  24. package/dist/types/elements/index.d.ts +116 -689
  25. package/dist/types/elements/typeChecks.d.ts +3 -3
  26. package/dist/types/elements/typeChecks.js +3 -8
  27. package/dist/types/geometryTypes.d.ts +1 -1
  28. package/dist/types/index.d.ts +38 -305
  29. package/dist/utils/constants.d.ts +3 -86
  30. package/dist/utils/constants.js +1 -197
  31. package/dist/utils/elements/index.d.ts +3 -14
  32. package/dist/utils/elements/index.js +7 -99
  33. package/dist/utils/elements/linearElement.d.ts +2 -2
  34. package/dist/utils/elements/newElement.d.ts +2 -12
  35. package/dist/utils/elements/newElement.js +22 -51
  36. package/dist/utils/elements/textElement.js +1 -1
  37. package/dist/utils/math/index.d.ts +5 -4
  38. package/dist/utils/math/index.js +3 -3
  39. package/dist/utils/shape.js +2 -2
  40. package/dist/utils/state/index.d.ts +0 -1
  41. package/dist/utils/state/index.js +4 -70
  42. package/dist/utils/traverse.d.ts +8 -0
  43. package/dist/utils/traverse.js +37 -0
  44. package/dist/version-control.d.ts +61 -0
  45. package/dist/version-control.js +84 -0
  46. package/dist/wasm.d.ts +20 -0
  47. package/dist/wasm.js +52 -0
  48. package/package.json +3 -2
  49. package/dist/flatbuffers/duc/alternate-units.d.ts +0 -21
  50. package/dist/flatbuffers/duc/alternate-units.js +0 -66
  51. package/dist/flatbuffers/duc/angular-unit-system.d.ts +0 -17
  52. package/dist/flatbuffers/duc/angular-unit-system.js +0 -50
  53. package/dist/flatbuffers/duc/angular-units-format.d.ts +0 -7
  54. package/dist/flatbuffers/duc/angular-units-format.js +0 -10
  55. package/dist/flatbuffers/duc/axis.d.ts +0 -5
  56. package/dist/flatbuffers/duc/axis.js +0 -8
  57. package/dist/flatbuffers/duc/bezier-mirroring.d.ts +0 -5
  58. package/dist/flatbuffers/duc/bezier-mirroring.js +0 -8
  59. package/dist/flatbuffers/duc/blending.d.ts +0 -9
  60. package/dist/flatbuffers/duc/blending.js +0 -12
  61. package/dist/flatbuffers/duc/block-attachment.d.ts +0 -4
  62. package/dist/flatbuffers/duc/block-attachment.js +0 -7
  63. package/dist/flatbuffers/duc/boolean-operation.d.ts +0 -6
  64. package/dist/flatbuffers/duc/boolean-operation.js +0 -9
  65. package/dist/flatbuffers/duc/bound-element.d.ts +0 -17
  66. package/dist/flatbuffers/duc/bound-element.js +0 -48
  67. package/dist/flatbuffers/duc/checkpoint.d.ts +0 -22
  68. package/dist/flatbuffers/duc/checkpoint.js +0 -75
  69. package/dist/flatbuffers/duc/column-layout.d.ts +0 -22
  70. package/dist/flatbuffers/duc/column-layout.js +0 -72
  71. package/dist/flatbuffers/duc/column-type.d.ts +0 -5
  72. package/dist/flatbuffers/duc/column-type.js +0 -8
  73. package/dist/flatbuffers/duc/custom-hatch-pattern.d.ts +0 -23
  74. package/dist/flatbuffers/duc/custom-hatch-pattern.js +0 -71
  75. package/dist/flatbuffers/duc/datum-bracket-style.d.ts +0 -5
  76. package/dist/flatbuffers/duc/datum-bracket-style.js +0 -8
  77. package/dist/flatbuffers/duc/datum-reference.d.ts +0 -17
  78. package/dist/flatbuffers/duc/datum-reference.js +0 -49
  79. package/dist/flatbuffers/duc/datum-target-type.d.ts +0 -6
  80. package/dist/flatbuffers/duc/datum-target-type.js +0 -9
  81. package/dist/flatbuffers/duc/decimal-separator.d.ts +0 -4
  82. package/dist/flatbuffers/duc/decimal-separator.js +0 -7
  83. package/dist/flatbuffers/duc/delta.d.ts +0 -22
  84. package/dist/flatbuffers/duc/delta.js +0 -75
  85. package/dist/flatbuffers/duc/dictionary-entry.d.ts +0 -17
  86. package/dist/flatbuffers/duc/dictionary-entry.js +0 -49
  87. package/dist/flatbuffers/duc/dimension-baseline-data.d.ts +0 -14
  88. package/dist/flatbuffers/duc/dimension-baseline-data.js +0 -40
  89. package/dist/flatbuffers/duc/dimension-bindings.d.ts +0 -17
  90. package/dist/flatbuffers/duc/dimension-bindings.js +0 -50
  91. package/dist/flatbuffers/duc/dimension-continue-data.d.ts +0 -14
  92. package/dist/flatbuffers/duc/dimension-continue-data.js +0 -40
  93. package/dist/flatbuffers/duc/dimension-definition-points.d.ts +0 -21
  94. package/dist/flatbuffers/duc/dimension-definition-points.js +0 -64
  95. package/dist/flatbuffers/duc/dimension-ext-line-style.d.ts +0 -18
  96. package/dist/flatbuffers/duc/dimension-ext-line-style.js +0 -57
  97. package/dist/flatbuffers/duc/dimension-fit-rule.d.ts +0 -6
  98. package/dist/flatbuffers/duc/dimension-fit-rule.js +0 -9
  99. package/dist/flatbuffers/duc/dimension-fit-style.d.ts +0 -19
  100. package/dist/flatbuffers/duc/dimension-fit-style.js +0 -58
  101. package/dist/flatbuffers/duc/dimension-line-style.d.ts +0 -16
  102. package/dist/flatbuffers/duc/dimension-line-style.js +0 -49
  103. package/dist/flatbuffers/duc/dimension-symbol-style.d.ts +0 -22
  104. package/dist/flatbuffers/duc/dimension-symbol-style.js +0 -72
  105. package/dist/flatbuffers/duc/dimension-text-placement.d.ts +0 -5
  106. package/dist/flatbuffers/duc/dimension-text-placement.js +0 -8
  107. package/dist/flatbuffers/duc/dimension-tolerance-style.d.ts +0 -24
  108. package/dist/flatbuffers/duc/dimension-tolerance-style.js +0 -71
  109. package/dist/flatbuffers/duc/dimension-type.d.ts +0 -15
  110. package/dist/flatbuffers/duc/dimension-type.js +0 -18
  111. package/dist/flatbuffers/duc/dimension-units-format.d.ts +0 -7
  112. package/dist/flatbuffers/duc/dimension-units-format.js +0 -10
  113. package/dist/flatbuffers/duc/dimension-validation-rules.d.ts +0 -25
  114. package/dist/flatbuffers/duc/dimension-validation-rules.js +0 -74
  115. package/dist/flatbuffers/duc/document-grid-align-items.d.ts +0 -5
  116. package/dist/flatbuffers/duc/document-grid-align-items.js +0 -8
  117. package/dist/flatbuffers/duc/document-grid-config.d.ts +0 -24
  118. package/dist/flatbuffers/duc/document-grid-config.js +0 -81
  119. package/dist/flatbuffers/duc/duc-arrow-element.d.ts +0 -16
  120. package/dist/flatbuffers/duc/duc-arrow-element.js +0 -49
  121. package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.d.ts +0 -16
  122. package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.js +0 -44
  123. package/dist/flatbuffers/duc/duc-block-attribute-definition.d.ts +0 -22
  124. package/dist/flatbuffers/duc/duc-block-attribute-definition.js +0 -64
  125. package/dist/flatbuffers/duc/duc-block-collection-entry.d.ts +0 -16
  126. package/dist/flatbuffers/duc/duc-block-collection-entry.js +0 -48
  127. package/dist/flatbuffers/duc/duc-block-collection.d.ts +0 -31
  128. package/dist/flatbuffers/duc/duc-block-collection.js +0 -97
  129. package/dist/flatbuffers/duc/duc-block-duplication-array.d.ts +0 -19
  130. package/dist/flatbuffers/duc/duc-block-duplication-array.js +0 -64
  131. package/dist/flatbuffers/duc/duc-block-instance-element.d.ts +0 -10
  132. package/dist/flatbuffers/duc/duc-block-instance-element.js +0 -28
  133. package/dist/flatbuffers/duc/duc-block-instance.d.ts +0 -32
  134. package/dist/flatbuffers/duc/duc-block-instance.js +0 -100
  135. package/dist/flatbuffers/duc/duc-block-metadata.d.ts +0 -26
  136. package/dist/flatbuffers/duc/duc-block-metadata.js +0 -90
  137. package/dist/flatbuffers/duc/duc-block.d.ts +0 -36
  138. package/dist/flatbuffers/duc/duc-block.js +0 -112
  139. package/dist/flatbuffers/duc/duc-common-style.d.ts +0 -16
  140. package/dist/flatbuffers/duc/duc-common-style.js +0 -44
  141. package/dist/flatbuffers/duc/duc-dimension-element.d.ts +0 -45
  142. package/dist/flatbuffers/duc/duc-dimension-element.js +0 -120
  143. package/dist/flatbuffers/duc/duc-dimension-style.d.ts +0 -28
  144. package/dist/flatbuffers/duc/duc-dimension-style.js +0 -76
  145. package/dist/flatbuffers/duc/duc-doc-element.d.ts +0 -39
  146. package/dist/flatbuffers/duc/duc-doc-element.js +0 -110
  147. package/dist/flatbuffers/duc/duc-doc-style.d.ts +0 -19
  148. package/dist/flatbuffers/duc/duc-doc-style.js +0 -52
  149. package/dist/flatbuffers/duc/duc-element-base.d.ts +0 -100
  150. package/dist/flatbuffers/duc/duc-element-base.js +0 -315
  151. package/dist/flatbuffers/duc/duc-element-styles-base.d.ts +0 -30
  152. package/dist/flatbuffers/duc/duc-element-styles-base.js +0 -103
  153. package/dist/flatbuffers/duc/duc-ellipse-element.d.ts +0 -22
  154. package/dist/flatbuffers/duc/duc-ellipse-element.js +0 -73
  155. package/dist/flatbuffers/duc/duc-embeddable-element.d.ts +0 -14
  156. package/dist/flatbuffers/duc/duc-embeddable-element.js +0 -41
  157. package/dist/flatbuffers/duc/duc-external-file-data.d.ts +0 -27
  158. package/dist/flatbuffers/duc/duc-external-file-data.js +0 -92
  159. package/dist/flatbuffers/duc/duc-external-file-entry.d.ts +0 -16
  160. package/dist/flatbuffers/duc/duc-external-file-entry.js +0 -44
  161. package/dist/flatbuffers/duc/duc-feature-control-frame-element.d.ts +0 -31
  162. package/dist/flatbuffers/duc/duc-feature-control-frame-element.js +0 -89
  163. package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +0 -22
  164. package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +0 -60
  165. package/dist/flatbuffers/duc/duc-frame-element.d.ts +0 -14
  166. package/dist/flatbuffers/duc/duc-frame-element.js +0 -41
  167. package/dist/flatbuffers/duc/duc-free-draw-element.d.ts +0 -52
  168. package/dist/flatbuffers/duc/duc-free-draw-element.js +0 -154
  169. package/dist/flatbuffers/duc/duc-free-draw-ends.d.ts +0 -18
  170. package/dist/flatbuffers/duc/duc-free-draw-ends.js +0 -56
  171. package/dist/flatbuffers/duc/duc-global-state.d.ts +0 -37
  172. package/dist/flatbuffers/duc/duc-global-state.js +0 -121
  173. package/dist/flatbuffers/duc/duc-group.d.ts +0 -16
  174. package/dist/flatbuffers/duc/duc-group.js +0 -44
  175. package/dist/flatbuffers/duc/duc-hatch-style.d.ts +0 -28
  176. package/dist/flatbuffers/duc/duc-hatch-style.js +0 -79
  177. package/dist/flatbuffers/duc/duc-head.d.ts +0 -19
  178. package/dist/flatbuffers/duc/duc-head.js +0 -57
  179. package/dist/flatbuffers/duc/duc-image-element.d.ts +0 -35
  180. package/dist/flatbuffers/duc/duc-image-element.js +0 -91
  181. package/dist/flatbuffers/duc/duc-image-filter.d.ts +0 -15
  182. package/dist/flatbuffers/duc/duc-image-filter.js +0 -48
  183. package/dist/flatbuffers/duc/duc-layer-overrides.d.ts +0 -16
  184. package/dist/flatbuffers/duc/duc-layer-overrides.js +0 -44
  185. package/dist/flatbuffers/duc/duc-layer.d.ts +0 -21
  186. package/dist/flatbuffers/duc/duc-layer.js +0 -59
  187. package/dist/flatbuffers/duc/duc-leader-element.d.ts +0 -22
  188. package/dist/flatbuffers/duc/duc-leader-element.js +0 -60
  189. package/dist/flatbuffers/duc/duc-leader-style.d.ts +0 -27
  190. package/dist/flatbuffers/duc/duc-leader-style.js +0 -79
  191. package/dist/flatbuffers/duc/duc-line-reference.d.ts +0 -15
  192. package/dist/flatbuffers/duc/duc-line-reference.js +0 -43
  193. package/dist/flatbuffers/duc/duc-line.d.ts +0 -15
  194. package/dist/flatbuffers/duc/duc-line.js +0 -43
  195. package/dist/flatbuffers/duc/duc-linear-element-base.d.ts +0 -38
  196. package/dist/flatbuffers/duc/duc-linear-element-base.js +0 -124
  197. package/dist/flatbuffers/duc/duc-linear-element.d.ts +0 -16
  198. package/dist/flatbuffers/duc/duc-linear-element.js +0 -49
  199. package/dist/flatbuffers/duc/duc-local-state.d.ts +0 -68
  200. package/dist/flatbuffers/duc/duc-local-state.js +0 -206
  201. package/dist/flatbuffers/duc/duc-mermaid-element.d.ts +0 -23
  202. package/dist/flatbuffers/duc/duc-mermaid-element.js +0 -65
  203. package/dist/flatbuffers/duc/duc-model-element.d.ts +0 -26
  204. package/dist/flatbuffers/duc/duc-model-element.js +0 -79
  205. package/dist/flatbuffers/duc/duc-parametric-element.d.ts +0 -16
  206. package/dist/flatbuffers/duc/duc-parametric-element.js +0 -44
  207. package/dist/flatbuffers/duc/duc-path.d.ts +0 -26
  208. package/dist/flatbuffers/duc/duc-path.js +0 -69
  209. package/dist/flatbuffers/duc/duc-pdf-element.d.ts +0 -19
  210. package/dist/flatbuffers/duc/duc-pdf-element.js +0 -51
  211. package/dist/flatbuffers/duc/duc-plot-element.d.ts +0 -19
  212. package/dist/flatbuffers/duc/duc-plot-element.js +0 -52
  213. package/dist/flatbuffers/duc/duc-plot-style.d.ts +0 -11
  214. package/dist/flatbuffers/duc/duc-plot-style.js +0 -32
  215. package/dist/flatbuffers/duc/duc-point-binding.d.ts +0 -26
  216. package/dist/flatbuffers/duc/duc-point-binding.js +0 -73
  217. package/dist/flatbuffers/duc/duc-point.d.ts +0 -18
  218. package/dist/flatbuffers/duc/duc-point.js +0 -57
  219. package/dist/flatbuffers/duc/duc-polygon-element.d.ts +0 -16
  220. package/dist/flatbuffers/duc/duc-polygon-element.js +0 -49
  221. package/dist/flatbuffers/duc/duc-rectangle-element.d.ts +0 -14
  222. package/dist/flatbuffers/duc/duc-rectangle-element.js +0 -41
  223. package/dist/flatbuffers/duc/duc-region.d.ts +0 -19
  224. package/dist/flatbuffers/duc/duc-region.js +0 -51
  225. package/dist/flatbuffers/duc/duc-stack-base.d.ts +0 -27
  226. package/dist/flatbuffers/duc/duc-stack-base.js +0 -78
  227. package/dist/flatbuffers/duc/duc-stack-element-base.d.ts +0 -23
  228. package/dist/flatbuffers/duc/duc-stack-element-base.js +0 -65
  229. package/dist/flatbuffers/duc/duc-stack-like-styles.d.ts +0 -16
  230. package/dist/flatbuffers/duc/duc-stack-like-styles.js +0 -48
  231. package/dist/flatbuffers/duc/duc-table-auto-size.d.ts +0 -15
  232. package/dist/flatbuffers/duc/duc-table-auto-size.js +0 -48
  233. package/dist/flatbuffers/duc/duc-table-cell-entry.d.ts +0 -16
  234. package/dist/flatbuffers/duc/duc-table-cell-entry.js +0 -44
  235. package/dist/flatbuffers/duc/duc-table-cell-span.d.ts +0 -15
  236. package/dist/flatbuffers/duc/duc-table-cell-span.js +0 -48
  237. package/dist/flatbuffers/duc/duc-table-cell-style.d.ts +0 -22
  238. package/dist/flatbuffers/duc/duc-table-cell-style.js +0 -59
  239. package/dist/flatbuffers/duc/duc-table-cell.d.ts +0 -27
  240. package/dist/flatbuffers/duc/duc-table-cell.js +0 -72
  241. package/dist/flatbuffers/duc/duc-table-column-entry.d.ts +0 -16
  242. package/dist/flatbuffers/duc/duc-table-column-entry.js +0 -44
  243. package/dist/flatbuffers/duc/duc-table-column.d.ts +0 -18
  244. package/dist/flatbuffers/duc/duc-table-column.js +0 -51
  245. package/dist/flatbuffers/duc/duc-table-element.d.ts +0 -51
  246. package/dist/flatbuffers/duc/duc-table-element.js +0 -167
  247. package/dist/flatbuffers/duc/duc-table-row-entry.d.ts +0 -16
  248. package/dist/flatbuffers/duc/duc-table-row-entry.js +0 -44
  249. package/dist/flatbuffers/duc/duc-table-row.d.ts +0 -18
  250. package/dist/flatbuffers/duc/duc-table-row.js +0 -51
  251. package/dist/flatbuffers/duc/duc-table-style.d.ts +0 -20
  252. package/dist/flatbuffers/duc/duc-table-style.js +0 -57
  253. package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.d.ts +0 -14
  254. package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.js +0 -40
  255. package/dist/flatbuffers/duc/duc-text-dynamic-element-source.d.ts +0 -17
  256. package/dist/flatbuffers/duc/duc-text-dynamic-element-source.js +0 -49
  257. package/dist/flatbuffers/duc/duc-text-dynamic-part.d.ts +0 -22
  258. package/dist/flatbuffers/duc/duc-text-dynamic-part.js +0 -58
  259. package/dist/flatbuffers/duc/duc-text-dynamic-source-data.d.ts +0 -9
  260. package/dist/flatbuffers/duc/duc-text-dynamic-source-data.js +0 -26
  261. package/dist/flatbuffers/duc/duc-text-dynamic-source.d.ts +0 -19
  262. package/dist/flatbuffers/duc/duc-text-dynamic-source.js +0 -58
  263. package/dist/flatbuffers/duc/duc-text-element.d.ts +0 -33
  264. package/dist/flatbuffers/duc/duc-text-element.js +0 -94
  265. package/dist/flatbuffers/duc/duc-text-style.d.ts +0 -41
  266. package/dist/flatbuffers/duc/duc-text-style.js +0 -120
  267. package/dist/flatbuffers/duc/duc-ucs.d.ts +0 -16
  268. package/dist/flatbuffers/duc/duc-ucs.js +0 -49
  269. package/dist/flatbuffers/duc/duc-view.d.ts +0 -24
  270. package/dist/flatbuffers/duc/duc-view.js +0 -71
  271. package/dist/flatbuffers/duc/duc-viewport-element.d.ts +0 -36
  272. package/dist/flatbuffers/duc/duc-viewport-element.js +0 -102
  273. package/dist/flatbuffers/duc/duc-viewport-style.d.ts +0 -13
  274. package/dist/flatbuffers/duc/duc-viewport-style.js +0 -40
  275. package/dist/flatbuffers/duc/duc-xray-element.d.ts +0 -23
  276. package/dist/flatbuffers/duc/duc-xray-element.js +0 -66
  277. package/dist/flatbuffers/duc/duc-xray-style.d.ts +0 -14
  278. package/dist/flatbuffers/duc/duc-xray-style.js +0 -40
  279. package/dist/flatbuffers/duc/dynamic-snap-settings.d.ts +0 -17
  280. package/dist/flatbuffers/duc/dynamic-snap-settings.js +0 -56
  281. package/dist/flatbuffers/duc/element-background.d.ts +0 -14
  282. package/dist/flatbuffers/duc/element-background.js +0 -41
  283. package/dist/flatbuffers/duc/element-content-base.d.ts +0 -29
  284. package/dist/flatbuffers/duc/element-content-base.js +0 -80
  285. package/dist/flatbuffers/duc/element-content-preference.d.ts +0 -8
  286. package/dist/flatbuffers/duc/element-content-preference.js +0 -11
  287. package/dist/flatbuffers/duc/element-stroke.d.ts +0 -24
  288. package/dist/flatbuffers/duc/element-stroke.js +0 -66
  289. package/dist/flatbuffers/duc/element-wrapper.d.ts +0 -16
  290. package/dist/flatbuffers/duc/element-wrapper.js +0 -49
  291. package/dist/flatbuffers/duc/element.d.ts +0 -51
  292. package/dist/flatbuffers/duc/element.js +0 -110
  293. package/dist/flatbuffers/duc/exported-data-state.d.ts +0 -102
  294. package/dist/flatbuffers/duc/exported-data-state.js +0 -341
  295. package/dist/flatbuffers/duc/fcfbetween-modifier.d.ts +0 -17
  296. package/dist/flatbuffers/duc/fcfbetween-modifier.js +0 -48
  297. package/dist/flatbuffers/duc/fcfdatum-definition.d.ts +0 -16
  298. package/dist/flatbuffers/duc/fcfdatum-definition.js +0 -43
  299. package/dist/flatbuffers/duc/fcfdatum-style.d.ts +0 -14
  300. package/dist/flatbuffers/duc/fcfdatum-style.js +0 -41
  301. package/dist/flatbuffers/duc/fcfframe-modifiers.d.ts +0 -22
  302. package/dist/flatbuffers/duc/fcfframe-modifiers.js +0 -65
  303. package/dist/flatbuffers/duc/fcflayout-style.d.ts +0 -17
  304. package/dist/flatbuffers/duc/fcflayout-style.js +0 -56
  305. package/dist/flatbuffers/duc/fcfprojected-zone-modifier.d.ts +0 -13
  306. package/dist/flatbuffers/duc/fcfprojected-zone-modifier.js +0 -40
  307. package/dist/flatbuffers/duc/fcfsegment-row.d.ts +0 -17
  308. package/dist/flatbuffers/duc/fcfsegment-row.js +0 -55
  309. package/dist/flatbuffers/duc/fcfsymbol-style.d.ts +0 -13
  310. package/dist/flatbuffers/duc/fcfsymbol-style.js +0 -40
  311. package/dist/flatbuffers/duc/feature-control-frame-segment.d.ts +0 -22
  312. package/dist/flatbuffers/duc/feature-control-frame-segment.js +0 -65
  313. package/dist/flatbuffers/duc/feature-modifier.d.ts +0 -18
  314. package/dist/flatbuffers/duc/feature-modifier.js +0 -21
  315. package/dist/flatbuffers/duc/gdt-symbol.d.ts +0 -22
  316. package/dist/flatbuffers/duc/gdt-symbol.js +0 -25
  317. package/dist/flatbuffers/duc/geometric-point.d.ts +0 -10
  318. package/dist/flatbuffers/duc/geometric-point.js +0 -27
  319. package/dist/flatbuffers/duc/grid-display-type.d.ts +0 -6
  320. package/dist/flatbuffers/duc/grid-display-type.js +0 -9
  321. package/dist/flatbuffers/duc/grid-settings.d.ts +0 -54
  322. package/dist/flatbuffers/duc/grid-settings.js +0 -165
  323. package/dist/flatbuffers/duc/grid-style.d.ts +0 -26
  324. package/dist/flatbuffers/duc/grid-style.js +0 -74
  325. package/dist/flatbuffers/duc/grid-type.d.ts +0 -7
  326. package/dist/flatbuffers/duc/grid-type.js +0 -10
  327. package/dist/flatbuffers/duc/handle-type.d.ts +0 -4
  328. package/dist/flatbuffers/duc/handle-type.js +0 -7
  329. package/dist/flatbuffers/duc/hatch-pattern-line.d.ts +0 -35
  330. package/dist/flatbuffers/duc/hatch-pattern-line.js +0 -93
  331. package/dist/flatbuffers/duc/hatch-style.d.ts +0 -5
  332. package/dist/flatbuffers/duc/hatch-style.js +0 -8
  333. package/dist/flatbuffers/duc/identified-common-style.d.ts +0 -16
  334. package/dist/flatbuffers/duc/identified-common-style.js +0 -44
  335. package/dist/flatbuffers/duc/identified-dimension-style.d.ts +0 -16
  336. package/dist/flatbuffers/duc/identified-dimension-style.js +0 -44
  337. package/dist/flatbuffers/duc/identified-doc-style.d.ts +0 -16
  338. package/dist/flatbuffers/duc/identified-doc-style.js +0 -44
  339. package/dist/flatbuffers/duc/identified-fcfstyle.d.ts +0 -16
  340. package/dist/flatbuffers/duc/identified-fcfstyle.js +0 -44
  341. package/dist/flatbuffers/duc/identified-grid-settings.d.ts +0 -16
  342. package/dist/flatbuffers/duc/identified-grid-settings.js +0 -44
  343. package/dist/flatbuffers/duc/identified-hatch-style.d.ts +0 -16
  344. package/dist/flatbuffers/duc/identified-hatch-style.js +0 -44
  345. package/dist/flatbuffers/duc/identified-leader-style.d.ts +0 -16
  346. package/dist/flatbuffers/duc/identified-leader-style.js +0 -44
  347. package/dist/flatbuffers/duc/identified-snap-settings.d.ts +0 -16
  348. package/dist/flatbuffers/duc/identified-snap-settings.js +0 -44
  349. package/dist/flatbuffers/duc/identified-stack-like-style.d.ts +0 -16
  350. package/dist/flatbuffers/duc/identified-stack-like-style.js +0 -44
  351. package/dist/flatbuffers/duc/identified-table-style.d.ts +0 -16
  352. package/dist/flatbuffers/duc/identified-table-style.js +0 -44
  353. package/dist/flatbuffers/duc/identified-text-style.d.ts +0 -16
  354. package/dist/flatbuffers/duc/identified-text-style.js +0 -44
  355. package/dist/flatbuffers/duc/identified-ucs.d.ts +0 -16
  356. package/dist/flatbuffers/duc/identified-ucs.js +0 -44
  357. package/dist/flatbuffers/duc/identified-view.d.ts +0 -16
  358. package/dist/flatbuffers/duc/identified-view.js +0 -44
  359. package/dist/flatbuffers/duc/identified-viewport-style.d.ts +0 -16
  360. package/dist/flatbuffers/duc/identified-viewport-style.js +0 -44
  361. package/dist/flatbuffers/duc/identified-xray-style.d.ts +0 -16
  362. package/dist/flatbuffers/duc/identified-xray-style.js +0 -44
  363. package/dist/flatbuffers/duc/identifier.d.ts +0 -20
  364. package/dist/flatbuffers/duc/identifier.js +0 -57
  365. package/dist/flatbuffers/duc/image-crop.d.ts +0 -23
  366. package/dist/flatbuffers/duc/image-crop.js +0 -80
  367. package/dist/flatbuffers/duc/image-status.d.ts +0 -5
  368. package/dist/flatbuffers/duc/image-status.js +0 -8
  369. package/dist/flatbuffers/duc/isometric-grid-settings.d.ts +0 -15
  370. package/dist/flatbuffers/duc/isometric-grid-settings.js +0 -48
  371. package/dist/flatbuffers/duc/jsonpatch-operation.d.ts +0 -23
  372. package/dist/flatbuffers/duc/jsonpatch-operation.js +0 -64
  373. package/dist/flatbuffers/duc/layer-snap-filters.d.ts +0 -23
  374. package/dist/flatbuffers/duc/layer-snap-filters.js +0 -76
  375. package/dist/flatbuffers/duc/layer-validation-rules.d.ts +0 -17
  376. package/dist/flatbuffers/duc/layer-validation-rules.js +0 -54
  377. package/dist/flatbuffers/duc/leader-block-content.d.ts +0 -25
  378. package/dist/flatbuffers/duc/leader-block-content.js +0 -85
  379. package/dist/flatbuffers/duc/leader-content-data.d.ts +0 -9
  380. package/dist/flatbuffers/duc/leader-content-data.js +0 -26
  381. package/dist/flatbuffers/duc/leader-content-type.d.ts +0 -4
  382. package/dist/flatbuffers/duc/leader-content-type.js +0 -7
  383. package/dist/flatbuffers/duc/leader-content.d.ts +0 -19
  384. package/dist/flatbuffers/duc/leader-content.js +0 -58
  385. package/dist/flatbuffers/duc/leader-text-block-content.d.ts +0 -14
  386. package/dist/flatbuffers/duc/leader-text-block-content.js +0 -40
  387. package/dist/flatbuffers/duc/line-head.d.ts +0 -17
  388. package/dist/flatbuffers/duc/line-head.js +0 -20
  389. package/dist/flatbuffers/duc/line-spacing-type.d.ts +0 -5
  390. package/dist/flatbuffers/duc/line-spacing-type.js +0 -8
  391. package/dist/flatbuffers/duc/line-spacing.d.ts +0 -16
  392. package/dist/flatbuffers/duc/line-spacing.js +0 -49
  393. package/dist/flatbuffers/duc/linear-unit-system.d.ts +0 -24
  394. package/dist/flatbuffers/duc/linear-unit-system.js +0 -75
  395. package/dist/flatbuffers/duc/margins.d.ts +0 -19
  396. package/dist/flatbuffers/duc/margins.js +0 -64
  397. package/dist/flatbuffers/duc/mark-ellipse-center.d.ts +0 -4
  398. package/dist/flatbuffers/duc/mark-ellipse-center.js +0 -7
  399. package/dist/flatbuffers/duc/material-condition.d.ts +0 -5
  400. package/dist/flatbuffers/duc/material-condition.js +0 -8
  401. package/dist/flatbuffers/duc/object-snap-mode.d.ts +0 -22
  402. package/dist/flatbuffers/duc/object-snap-mode.js +0 -25
  403. package/dist/flatbuffers/duc/paragraph-formatting.d.ts +0 -33
  404. package/dist/flatbuffers/duc/paragraph-formatting.js +0 -106
  405. package/dist/flatbuffers/duc/parametric-source-type.d.ts +0 -4
  406. package/dist/flatbuffers/duc/parametric-source-type.js +0 -7
  407. package/dist/flatbuffers/duc/parametric-source.d.ts +0 -20
  408. package/dist/flatbuffers/duc/parametric-source.js +0 -57
  409. package/dist/flatbuffers/duc/plot-layout.d.ts +0 -14
  410. package/dist/flatbuffers/duc/plot-layout.js +0 -41
  411. package/dist/flatbuffers/duc/point-binding-point.d.ts +0 -15
  412. package/dist/flatbuffers/duc/point-binding-point.js +0 -48
  413. package/dist/flatbuffers/duc/polar-grid-settings.d.ts +0 -17
  414. package/dist/flatbuffers/duc/polar-grid-settings.js +0 -56
  415. package/dist/flatbuffers/duc/polar-tracking-settings.d.ts +0 -29
  416. package/dist/flatbuffers/duc/polar-tracking-settings.js +0 -90
  417. package/dist/flatbuffers/duc/primary-units.d.ts +0 -16
  418. package/dist/flatbuffers/duc/primary-units.js +0 -44
  419. package/dist/flatbuffers/duc/pruning-level.d.ts +0 -5
  420. package/dist/flatbuffers/duc/pruning-level.js +0 -8
  421. package/dist/flatbuffers/duc/snap-marker-settings.d.ts +0 -23
  422. package/dist/flatbuffers/duc/snap-marker-settings.js +0 -79
  423. package/dist/flatbuffers/duc/snap-marker-shape.d.ts +0 -6
  424. package/dist/flatbuffers/duc/snap-marker-shape.js +0 -9
  425. package/dist/flatbuffers/duc/snap-marker-style-entry.d.ts +0 -16
  426. package/dist/flatbuffers/duc/snap-marker-style-entry.js +0 -43
  427. package/dist/flatbuffers/duc/snap-marker-style.d.ts +0 -17
  428. package/dist/flatbuffers/duc/snap-marker-style.js +0 -49
  429. package/dist/flatbuffers/duc/snap-mode.d.ts +0 -4
  430. package/dist/flatbuffers/duc/snap-mode.js +0 -7
  431. package/dist/flatbuffers/duc/snap-override-behavior.d.ts +0 -5
  432. package/dist/flatbuffers/duc/snap-override-behavior.js +0 -8
  433. package/dist/flatbuffers/duc/snap-override.d.ts +0 -17
  434. package/dist/flatbuffers/duc/snap-override.js +0 -49
  435. package/dist/flatbuffers/duc/snap-settings.d.ts +0 -75
  436. package/dist/flatbuffers/duc/snap-settings.js +0 -245
  437. package/dist/flatbuffers/duc/stack-format-properties.d.ts +0 -18
  438. package/dist/flatbuffers/duc/stack-format-properties.js +0 -57
  439. package/dist/flatbuffers/duc/stack-format.d.ts +0 -21
  440. package/dist/flatbuffers/duc/stack-format.js +0 -64
  441. package/dist/flatbuffers/duc/stacked-text-align.d.ts +0 -5
  442. package/dist/flatbuffers/duc/stacked-text-align.js +0 -8
  443. package/dist/flatbuffers/duc/standard-overrides.d.ts +0 -63
  444. package/dist/flatbuffers/duc/standard-overrides.js +0 -162
  445. package/dist/flatbuffers/duc/standard-styles.d.ts +0 -77
  446. package/dist/flatbuffers/duc/standard-styles.js +0 -285
  447. package/dist/flatbuffers/duc/standard-units.d.ts +0 -16
  448. package/dist/flatbuffers/duc/standard-units.js +0 -44
  449. package/dist/flatbuffers/duc/standard-validation.d.ts +0 -16
  450. package/dist/flatbuffers/duc/standard-validation.js +0 -44
  451. package/dist/flatbuffers/duc/standard-view-settings.d.ts +0 -35
  452. package/dist/flatbuffers/duc/standard-view-settings.js +0 -124
  453. package/dist/flatbuffers/duc/standard.d.ts +0 -33
  454. package/dist/flatbuffers/duc/standard.js +0 -90
  455. package/dist/flatbuffers/duc/string-value-entry.d.ts +0 -17
  456. package/dist/flatbuffers/duc/string-value-entry.js +0 -49
  457. package/dist/flatbuffers/duc/stroke-cap.d.ts +0 -5
  458. package/dist/flatbuffers/duc/stroke-cap.js +0 -8
  459. package/dist/flatbuffers/duc/stroke-join.d.ts +0 -5
  460. package/dist/flatbuffers/duc/stroke-join.js +0 -8
  461. package/dist/flatbuffers/duc/stroke-placement.d.ts +0 -5
  462. package/dist/flatbuffers/duc/stroke-placement.js +0 -8
  463. package/dist/flatbuffers/duc/stroke-preference.d.ts +0 -6
  464. package/dist/flatbuffers/duc/stroke-preference.js +0 -9
  465. package/dist/flatbuffers/duc/stroke-side-preference.d.ts +0 -8
  466. package/dist/flatbuffers/duc/stroke-side-preference.js +0 -11
  467. package/dist/flatbuffers/duc/stroke-sides.d.ts +0 -24
  468. package/dist/flatbuffers/duc/stroke-sides.js +0 -67
  469. package/dist/flatbuffers/duc/stroke-style.d.ts +0 -37
  470. package/dist/flatbuffers/duc/stroke-style.js +0 -111
  471. package/dist/flatbuffers/duc/stroke-width.d.ts +0 -5
  472. package/dist/flatbuffers/duc/stroke-width.js +0 -8
  473. package/dist/flatbuffers/duc/table-cell-alignment.d.ts +0 -11
  474. package/dist/flatbuffers/duc/table-cell-alignment.js +0 -14
  475. package/dist/flatbuffers/duc/table-flow-direction.d.ts +0 -4
  476. package/dist/flatbuffers/duc/table-flow-direction.js +0 -7
  477. package/dist/flatbuffers/duc/text-align.d.ts +0 -5
  478. package/dist/flatbuffers/duc/text-align.js +0 -8
  479. package/dist/flatbuffers/duc/text-column.d.ts +0 -15
  480. package/dist/flatbuffers/duc/text-column.js +0 -48
  481. package/dist/flatbuffers/duc/text-field-source-property.d.ts +0 -13
  482. package/dist/flatbuffers/duc/text-field-source-property.js +0 -16
  483. package/dist/flatbuffers/duc/text-field-source-type.d.ts +0 -4
  484. package/dist/flatbuffers/duc/text-field-source-type.js +0 -7
  485. package/dist/flatbuffers/duc/text-flow-direction.d.ts +0 -6
  486. package/dist/flatbuffers/duc/text-flow-direction.js +0 -9
  487. package/dist/flatbuffers/duc/tiling-properties.d.ts +0 -21
  488. package/dist/flatbuffers/duc/tiling-properties.js +0 -75
  489. package/dist/flatbuffers/duc/tolerance-clause.d.ts +0 -27
  490. package/dist/flatbuffers/duc/tolerance-clause.js +0 -84
  491. package/dist/flatbuffers/duc/tolerance-display.d.ts +0 -7
  492. package/dist/flatbuffers/duc/tolerance-display.js +0 -10
  493. package/dist/flatbuffers/duc/tolerance-type.d.ts +0 -5
  494. package/dist/flatbuffers/duc/tolerance-type.js +0 -8
  495. package/dist/flatbuffers/duc/tolerance-zone-type.d.ts +0 -7
  496. package/dist/flatbuffers/duc/tolerance-zone-type.js +0 -10
  497. package/dist/flatbuffers/duc/tracking-line-style.d.ts +0 -26
  498. package/dist/flatbuffers/duc/tracking-line-style.js +0 -74
  499. package/dist/flatbuffers/duc/unit-precision.d.ts +0 -19
  500. package/dist/flatbuffers/duc/unit-precision.js +0 -64
  501. package/dist/flatbuffers/duc/unit-system-base.d.ts +0 -20
  502. package/dist/flatbuffers/duc/unit-system-base.js +0 -65
  503. package/dist/flatbuffers/duc/unit-system.d.ts +0 -4
  504. package/dist/flatbuffers/duc/unit-system.js +0 -7
  505. package/dist/flatbuffers/duc/version-base.d.ts +0 -27
  506. package/dist/flatbuffers/duc/version-base.js +0 -80
  507. package/dist/flatbuffers/duc/version-graph-metadata.d.ts +0 -15
  508. package/dist/flatbuffers/duc/version-graph-metadata.js +0 -48
  509. package/dist/flatbuffers/duc/version-graph.d.ts +0 -31
  510. package/dist/flatbuffers/duc/version-graph.js +0 -94
  511. package/dist/flatbuffers/duc/vertical-align.d.ts +0 -5
  512. package/dist/flatbuffers/duc/vertical-align.js +0 -8
  513. package/dist/flatbuffers/duc/viewport-shade-plot.d.ts +0 -6
  514. package/dist/flatbuffers/duc/viewport-shade-plot.js +0 -9
  515. package/dist/flatbuffers/duc/youtube-states.d.ts +0 -8
  516. package/dist/flatbuffers/duc/youtube-states.js +0 -11
  517. package/dist/flatbuffers/duc.d.ts +0 -234
  518. package/dist/flatbuffers/duc.js +0 -236
  519. package/dist/restore/restoreStandards.d.ts +0 -8
  520. package/dist/restore/restoreStandards.js +0 -224
  521. package/dist/technical/standards.d.ts +0 -124
  522. package/dist/technical/standards.js +0 -10
  523. package/dist/utils/elements/viewportElement.d.ts +0 -6
  524. package/dist/utils/elements/viewportElement.js +0 -9
  525. package/dist/utils/state/grid.d.ts +0 -7
  526. package/dist/utils/state/grid.js +0 -25
@@ -1,207 +1,135 @@
1
+ import { wasmGetExternalFile, wasmListExternalFiles } from "./wasm";
1
2
  /**
2
- * LazyExternalFileStore Zero-copy, on-demand access to external file data from a FlatBuffer.
3
+ * Provides lazy access to external files embedded inside a `.duc` buffer.
3
4
  *
4
- * Instead of eagerly parsing and copying every external file's binary data into JS memory,
5
- * this store keeps a reference to the original FlatBuffer Uint8Array and reads file bytes
6
- * only when explicitly requested. FlatBuffer `dataArray()` returns a zero-copy view
7
- * (a Uint8Array pointing into the original buffer), so no allocation occurs until the
8
- * consumer actually needs the data.
9
- *
10
- * Memory lifecycle:
11
- * 1. On parse: only metadata (~200 bytes per file) enters JS heap.
12
- * 2. On demand: `getFileData(fileId)` reads the zero-copy slice from the buffer.
13
- * 3. The caller (renderer/worker) uses the data, then lets it GC naturally.
14
- * 4. If the store is released, the buffer reference is dropped, freeing everything.
15
- *
16
- * This is the key to supporting 1000s of external files without RAM bloat.
5
+ * Instead of loading all file blobs into memory at parse time, this store
6
+ * keeps a reference to the raw `.duc` buffer and fetches individual files
7
+ * on demand via WASM calls.
17
8
  */
18
- var __rest = (this && this.__rest) || function (s, e) {
19
- var t = {};
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
21
- t[p] = s[p];
22
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
23
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
24
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
25
- t[p[i]] = s[p[i]];
26
- }
27
- return t;
28
- };
29
- import * as flatbuffers from "flatbuffers";
30
- import { ExportedDataState as ExportedDataStateFb } from "./flatbuffers/duc";
31
9
  export class LazyExternalFileStore {
32
10
  constructor(buffer) {
33
- /** Map from file id → lazy entry */
34
- this._entries = new Map();
35
- /** Map from element key → file id (the external_files vector uses element id as key) */
36
- this._keyToFileId = new Map();
37
- /**
38
- * Files that were added at runtime (e.g. user uploading a new image).
39
- * These aren't in the original FlatBuffer so we hold their data directly.
40
- */
41
- this._runtimeFiles = new Map();
42
- this._buffer = buffer;
43
- this._byteBuffer = new flatbuffers.ByteBuffer(buffer);
44
- this._dataState = ExportedDataStateFb.getRootAsExportedDataState(this._byteBuffer);
45
- this._indexMetadata();
46
- console.info(`[LazyExternalFileStore] indexed ${this._entries.size} files from ${buffer.byteLength} byte buffer, ids: [${[...this._entries.keys()].map(k => k.slice(0, 12)).join(', ')}]`);
11
+ this.metadataCache = null;
12
+ this.runtimeFiles = new Map();
13
+ this.buffer = buffer;
47
14
  }
48
- _indexMetadata() {
49
- if (!this._dataState)
50
- return;
51
- const count = this._dataState.externalFilesLength();
52
- for (let i = 0; i < count; i++) {
53
- const entry = this._dataState.externalFiles(i);
54
- if (!entry)
55
- continue;
56
- const key = entry.key();
57
- const fileData = entry.value();
58
- if (!key || !fileData)
59
- continue;
60
- const id = fileData.id();
61
- if (!id)
62
- continue;
63
- const metadata = {
64
- id,
65
- mimeType: fileData.mimeType() || "application/octet-stream",
66
- created: Number(fileData.created()),
67
- lastRetrieved: Number(fileData.lastRetrieved()) || undefined,
68
- };
69
- const lazyEntry = { metadata, vectorIndex: i };
70
- this._entries.set(id, lazyEntry);
71
- this._keyToFileId.set(key, id);
72
- }
15
+ get isReleased() {
16
+ return this.buffer === null;
73
17
  }
74
- /** Total number of external files */
75
18
  get size() {
76
- return this._entries.size + this._runtimeFiles.size;
19
+ return this.getMetadataMap().size + this.runtimeFiles.size;
77
20
  }
78
- /** Whether a file with the given id exists */
21
+ /** Check if a file with this ID exists. */
79
22
  has(fileId) {
80
- return this._entries.has(fileId) || this._runtimeFiles.has(fileId);
23
+ return this.runtimeFiles.has(fileId) || this.getMetadataMap().has(fileId);
81
24
  }
82
- /** Get metadata only (no binary data copied) ~200 bytes per file */
25
+ /** Get metadata (without data blob) for a specific file. */
83
26
  getMetadata(fileId) {
84
- var _a, _b;
85
- const runtime = this._runtimeFiles.get(fileId);
86
- if (runtime) {
87
- const { data: _ } = runtime, meta = __rest(runtime, ["data"]);
88
- return meta;
27
+ const rt = this.runtimeFiles.get(fileId);
28
+ if (rt) {
29
+ return {
30
+ id: rt.id,
31
+ mimeType: rt.mimeType,
32
+ created: rt.created,
33
+ lastRetrieved: rt.lastRetrieved,
34
+ version: rt.version,
35
+ };
89
36
  }
90
- return (_b = (_a = this._entries.get(fileId)) === null || _a === void 0 ? void 0 : _a.metadata) !== null && _b !== void 0 ? _b : null;
37
+ return this.getMetadataMap().get(fileId);
91
38
  }
92
- /** Get all metadata entries (for UI listing, etc.) */
39
+ /** Get metadata for all files. */
93
40
  getAllMetadata() {
94
- const result = {};
95
- for (const [id, entry] of this._entries) {
96
- result[id] = entry.metadata;
41
+ const result = [];
42
+ for (const meta of this.getMetadataMap().values()) {
43
+ result.push(meta);
97
44
  }
98
- for (const [id, file] of this._runtimeFiles) {
99
- const { data: _ } = file, meta = __rest(file, ["data"]);
100
- result[id] = meta;
45
+ for (const [id, data] of this.runtimeFiles) {
46
+ if (!this.getMetadataMap().has(id)) {
47
+ result.push({
48
+ id: data.id,
49
+ mimeType: data.mimeType,
50
+ created: data.created,
51
+ lastRetrieved: data.lastRetrieved,
52
+ version: data.version,
53
+ });
54
+ }
101
55
  }
102
56
  return result;
103
57
  }
104
- /**
105
- * Get full file data (metadata + binary bytes) ON DEMAND.
106
- *
107
- * For files from the original FlatBuffer, this returns a zero-copy Uint8Array
108
- * view into the original buffer — no allocation for the file bytes themselves.
109
- * The view is valid as long as this store hasn't been released.
110
- *
111
- * For runtime-added files, returns the data directly.
112
- */
58
+ /** Fetch the full file data (including blob) for a specific file. */
113
59
  getFileData(fileId) {
114
- const runtime = this._runtimeFiles.get(fileId);
115
- if (runtime)
116
- return runtime;
117
- const entry = this._entries.get(fileId);
118
- if (!entry || !this._dataState)
119
- return null;
120
- const fbEntry = this._dataState.externalFiles(entry.vectorIndex);
121
- if (!fbEntry)
60
+ const rt = this.runtimeFiles.get(fileId);
61
+ if (rt)
62
+ return rt;
63
+ if (!this.buffer)
122
64
  return null;
123
- const fileData = fbEntry.value();
124
- if (!fileData)
65
+ const result = wasmGetExternalFile(this.buffer, fileId);
66
+ if (!result)
125
67
  return null;
126
- const data = fileData.dataArray();
127
- if (!data)
128
- return null;
129
- return Object.assign(Object.assign({}, entry.metadata), { data });
68
+ // WASM returns DucExternalFileEntry { key, value: DucExternalFileData }.
69
+ // Unwrap to get the actual file data.
70
+ const entry = result;
71
+ if (entry.value && typeof entry.value === "object") {
72
+ return entry.value;
73
+ }
74
+ return entry;
130
75
  }
131
- /**
132
- * Get a detached copy of the file data (allocates new ArrayBuffer).
133
- * Use this when you need to transfer data to a worker or keep it beyond store lifetime.
134
- */
76
+ /** Fetch file data and return a copy of the data buffer (safe for transfer). */
135
77
  getFileDataCopy(fileId) {
136
- const fileDataRef = this.getFileData(fileId);
137
- if (!fileDataRef)
78
+ const data = this.getFileData(fileId);
79
+ if (!data)
138
80
  return null;
139
- return Object.assign(Object.assign({}, fileDataRef), { data: new Uint8Array(fileDataRef.data) });
81
+ return Object.assign(Object.assign({}, data), { data: new Uint8Array(data.data) });
140
82
  }
141
- /**
142
- * Add a file at runtime (user upload, paste, etc.).
143
- * These files are held in memory since they aren't in the FlatBuffer.
144
- */
145
- addRuntimeFile(fileData) {
146
- this._runtimeFiles.set(fileData.id, fileData);
83
+ /** Add a file at runtime (not persisted in .duc until next serialize). */
84
+ addRuntimeFile(fileId, data) {
85
+ this.runtimeFiles.set(fileId, data);
147
86
  }
148
- /** Remove a runtime-added file */
87
+ /** Remove a runtime file. */
149
88
  removeRuntimeFile(fileId) {
150
- this._runtimeFiles.delete(fileId);
89
+ return this.runtimeFiles.delete(fileId);
151
90
  }
152
- /**
153
- * Export all files as a standard DucExternalFiles record.
154
- * This COPIES all file data eagerly — use only for serialization.
155
- */
91
+ /** Export all files eagerly as a DucExternalFiles record. */
156
92
  toExternalFiles() {
157
93
  const result = {};
158
- for (const [key, fileId] of this._keyToFileId) {
159
- const fileData = this.getFileData(fileId);
160
- if (fileData) {
161
- result[key] = fileData;
94
+ if (this.buffer) {
95
+ const metas = this.getMetadataMap();
96
+ for (const [id] of metas) {
97
+ const data = this.getFileData(id);
98
+ if (data) {
99
+ result[id] = data;
100
+ }
162
101
  }
163
102
  }
164
- for (const [id, file] of this._runtimeFiles) {
165
- result[id] = file;
103
+ for (const [id, data] of this.runtimeFiles) {
104
+ result[id] = data;
166
105
  }
167
106
  return result;
168
107
  }
169
- /**
170
- * Merge runtime files from the given DucExternalFiles map.
171
- * Only adds files not already present in the store.
172
- */
108
+ /** Merge files from another source (only adds missing). */
173
109
  mergeFiles(files) {
174
- for (const [_key, fileData] of Object.entries(files)) {
175
- if (!this.has(fileData.id)) {
176
- this.addRuntimeFile(fileData);
110
+ for (const [id, data] of Object.entries(files)) {
111
+ if (!this.has(id)) {
112
+ this.runtimeFiles.set(id, data);
177
113
  }
178
114
  }
179
115
  }
180
- /** Estimated RAM usage for metadata only (not counting the backing buffer) */
181
- get estimatedMetadataBytes() {
182
- var _a, _b;
183
- let bytes = 0;
184
- for (const [, entry] of this._entries) {
185
- bytes += 200 + entry.metadata.id.length * 2 + entry.metadata.mimeType.length * 2;
186
- }
187
- for (const [, file] of this._runtimeFiles) {
188
- bytes += 200 + ((_b = (_a = file.data) === null || _a === void 0 ? void 0 : _a.byteLength) !== null && _b !== void 0 ? _b : 0);
189
- }
190
- return bytes;
191
- }
192
- /**
193
- * Release the FlatBuffer reference. After this, only runtime-added files remain accessible.
194
- * Call this when switching documents or when the store is no longer needed.
195
- */
116
+ /** Release the underlying buffer to free memory. */
196
117
  release() {
197
- this._buffer = null;
198
- this._byteBuffer = null;
199
- this._dataState = null;
200
- this._entries.clear();
201
- this._keyToFileId.clear();
118
+ this.buffer = null;
119
+ this.metadataCache = null;
202
120
  }
203
- /** Whether the store has been released */
204
- get isReleased() {
205
- return this._buffer === null;
121
+ getMetadataMap() {
122
+ if (!this.metadataCache) {
123
+ this.metadataCache = new Map();
124
+ if (this.buffer) {
125
+ const metas = wasmListExternalFiles(this.buffer);
126
+ if (metas) {
127
+ for (const meta of metas) {
128
+ this.metadataCache.set(meta.id, meta);
129
+ }
130
+ }
131
+ }
132
+ }
133
+ return this.metadataCache;
206
134
  }
207
135
  }
package/dist/parse.d.ts CHANGED
@@ -1,87 +1,21 @@
1
- import { FileSystemHandle } from 'browser-fs-access';
2
- import { CustomHatchPattern as CustomHatchPatternFb, DimensionToleranceStyle as DimensionToleranceStyleFb, DocumentGridConfig as DocumentGridConfigFb, DucBlock as DucBlockFb, DucDimensionStyle as DucDimensionStyleFb, DucDocStyle as DucDocStyleFb, DucExternalFileEntry, DucFeatureControlFrameStyle as DucFeatureControlFrameStyleFb, DucGlobalState as DucGlobalStateFb, DucGroup as DucGroupFb, DucHatchStyle as DucHatchStyleFb, DucHead as DucHeadFb, DucImageFilter as DucImageFilterFb, DucLayer as DucLayerFb, DucLeaderStyle as DucLeaderStyleFb, DucLine as DucLineFb, DucLineReference as DucLineReferenceFb, DucLocalState as DucLocalStateFb, DucPath as DucPathFb, DucPlotStyle as DucPlotStyleFb, DucPointBinding as DucPointBindingFb, DucPoint as DucPointFb, DucRegion as DucRegionFb, DucStackLikeStyles as DucStackLikeStylesFb, DucTableCellStyle as DucTableCellStyleFb, DucTableStyle as DucTableStyleFb, DucTextStyle as DucTextStyleFb, DucViewportStyle as DucViewportStyleFb, DucXRayStyle as DucXRayStyleFb, ElementBackground as ElementBackgroundFb, ElementContentBase as ElementContentBaseFb, ElementStroke as ElementStrokeFb, ElementWrapper, ExportedDataState as ExportedDataStateFb, GeometricPoint as GeometricPointFb, HatchPatternLine as HatchPatternLineFb, Margins as MarginsFb, PrimaryUnits as PrimaryUnitsFb, Standard as StandardFb, StrokeSides as StrokeSidesFb, StrokeStyle as StrokeStyleFb, TilingProperties as TilingPropertiesFb, VersionGraph as VersionGraphFb, _DucElementBase as _DucElementBaseFb, _DucElementStylesBase as _DucElementStylesBaseFb, _DucLinearElementBase as _DucLinearElementBaseFb, _DucStackBase as _DucStackBaseFb, _DucStackElementBase as _DucStackElementBaseFb } from "./flatbuffers/duc";
3
- import { RestoreConfig, RestoredDataState } from "./restore";
4
- import { Standard, StandardUnits } from "./technical";
5
- import { CustomHatchPattern, Dictionary, DocumentGridConfig, DucBlock, DucDimensionStyle, DucDocStyle, DucElement, DucExternalFileMetadata, DucExternalFiles, DucFeatureControlFrameStyle, DucGlobalState, DucGroup, DucHatchStyle, DucHead, DucImageFilter, DucLayer, DucLeaderStyle, DucLine, DucLineReference, DucLocalState, DucPath, DucPlotStyle, DucPoint, DucPointBinding, DucRegion, DucStackLikeStyles, DucTableCellStyle, DucTableStyle, DucTextStyle, DucViewportStyle, DucXRayStyle, ElementBackground, ElementContentBase, ElementStroke, GeometricPoint, HatchPatternLine, PlotLayout, StrokeSides, StrokeStyle, TilingProperties, VersionGraph, _DucElementBase, _DucElementStylesBase, _DucLinearElementBase, _DucStackBase, _DucStackElementBase } from "./types";
6
- export declare function parseGeometricPoint(point: GeometricPointFb): GeometricPoint;
7
- export declare function parsePoint(point: DucPointFb): DucPoint;
8
- export declare function parseMargins(margins: MarginsFb): PlotLayout["margins"];
9
- export declare function parseDocumentGridConfig(gridConfig: DocumentGridConfigFb): DocumentGridConfig;
10
- export declare function parseHead(head: DucHeadFb): DucHead;
11
- export declare function parseHatchPatternLine(line: HatchPatternLineFb): HatchPatternLine;
12
- export declare function parseCustomHatchPattern(pattern: CustomHatchPatternFb): CustomHatchPattern;
13
- export declare function parseHatchStyle(hatch: DucHatchStyleFb): DucHatchStyle;
14
- export declare function parseTilingProperties(tiling: TilingPropertiesFb): TilingProperties;
15
- export declare function parseImageFilter(filter: DucImageFilterFb): DucImageFilter;
16
- export declare function parseElementContentBase(content: ElementContentBaseFb): ElementContentBase;
17
- export declare function parseStrokeStyle(style: StrokeStyleFb): StrokeStyle;
18
- export declare function parseStrokeSides(sides: StrokeSidesFb): StrokeSides;
19
- export declare function parseElementStroke(stroke: ElementStrokeFb): ElementStroke;
20
- export declare function parseElementBackground(background: ElementBackgroundFb): ElementBackground;
21
- export declare function parseElementStylesBase(styles: _DucElementStylesBaseFb): _DucElementStylesBase;
22
- export declare function parseElementBase(base: _DucElementBaseFb): _DucElementBase;
23
- export declare function parseLineReference(ref: DucLineReferenceFb): DucLineReference;
24
- export declare function parseLine(line: DucLineFb): DucLine;
25
- export declare function parsePath(path: DucPathFb): DucPath;
26
- export declare function parsePointBinding(binding: DucPointBindingFb): DucPointBinding;
27
- export declare function parseLinearElementBase(base: _DucLinearElementBaseFb): _DucLinearElementBase;
28
- export declare function parseStackLikeStyles(styles: DucStackLikeStylesFb): DucStackLikeStyles;
29
- export declare function parseStackBase(base: _DucStackBaseFb): _DucStackBase;
30
- export declare function parseStackElementBase(base: _DucStackElementBaseFb): _DucStackElementBase;
31
- export declare function parseTextStyle(style: DucTextStyleFb): DucTextStyle;
32
- export declare function parseTableCellStyle(style: DucTableCellStyleFb): DucTableCellStyle;
33
- export declare function parseTableStyle(style: DucTableStyleFb): DucTableStyle;
34
- export declare function parsePlotStyle(style: DucPlotStyleFb): DucPlotStyle;
35
- export declare function parseViewportStyle(style: DucViewportStyleFb): DucViewportStyle;
36
- export declare function parseXRayStyle(style: DucXRayStyleFb): DucXRayStyle;
37
- export declare function parseLeaderStyle(style: DucLeaderStyleFb): DucLeaderStyle;
38
- export declare function parseDimensionToleranceStyle(style: DimensionToleranceStyleFb): DucDimensionStyle["tolerance"];
39
- export declare function parseDimensionStyle(style: DucDimensionStyleFb): DucDimensionStyle;
40
- export declare function parseFeatureControlFrameStyle(style: DucFeatureControlFrameStyleFb): DucFeatureControlFrameStyle;
41
- export declare function parseDocStyle(style: DucDocStyleFb): DucDocStyle;
42
- export declare function parseElementFromBinary(wrapper: ElementWrapper): DucElement | null;
43
- export declare function parseBlockFromBinary(block: DucBlockFb): DucBlock;
44
- export declare function parseDictionaryFromBinary(data: ExportedDataStateFb): Dictionary;
45
- export declare function parseExternalFilesFromBinary(entry: DucExternalFileEntry): DucExternalFiles;
46
- /**
47
- * Parse only metadata (no binary data) from an external file entry.
48
- * Used by the lazy file store to avoid copying file bytes into JS memory.
49
- */
50
- export declare function parseExternalFileMetadataFromBinary(entry: DucExternalFileEntry): {
51
- key: string;
52
- metadata: DucExternalFileMetadata;
53
- } | null;
54
- export declare function parseGlobalStateFromBinary(state: DucGlobalStateFb): DucGlobalState;
55
- export declare function parseGroupFromBinary(group: DucGroupFb): DucGroup;
56
- export declare function parseLayerFromBinary(layer: DucLayerFb): DucLayer;
57
- export declare function parseLocalStateFromBinary(state: DucLocalStateFb): DucLocalState;
58
- export declare function parseRegionFromBinary(region: DucRegionFb): DucRegion;
59
- export declare function parsePrimaryUnits(units: PrimaryUnitsFb): StandardUnits["primaryUnits"];
60
- export declare function parseStandardFromBinary(standard: StandardFb): Standard;
61
- export declare function parseThumbnailFromBinary(data: ExportedDataStateFb): Uint8Array | undefined;
62
- export declare function parseVersionGraphFromBinary(graph: VersionGraphFb | null): VersionGraph | null;
63
- export declare const parseDuc: (blob: Blob | File, fileHandle?: FileSystemHandle | null, restoreConfig?: RestoreConfig) => Promise<RestoredDataState>;
64
- import { LazyExternalFileStore } from "./lazy-files";
65
- export type LazyRestoredDataState = Omit<RestoredDataState, 'files'> & {
66
- /** Lazy file store: only metadata is in memory, file bytes are read on-demand from the buffer */
1
+ import { type ElementsConfig, type RestoreConfig, type RestoredDataState } from "./restore";
2
+ export type { RestoredDataState };
3
+ export type LazyRestoredDataState = RestoredDataState & {
67
4
  lazyFileStore: LazyExternalFileStore;
68
- /** Legacy `files` field — always empty. Use lazyFileStore instead. */
69
- files: DucExternalFiles;
70
5
  };
6
+ import { LazyExternalFileStore } from "./lazy-files";
7
+ export { LazyExternalFileStore };
71
8
  /**
72
- * Parse a .duc binary with lazy external file loading.
9
+ * Parse a `.duc` file (Blob/File) into a RestoredDataState.
73
10
  *
74
- * This is identical to `parseDuc` except:
75
- * - External file BYTES are NOT copied into JS memory.
76
- * - Only file metadata (~200 bytes per file) is parsed.
77
- * - A `LazyExternalFileStore` is returned for on-demand data access.
78
- * - The store holds a reference to the original Uint8Array buffer.
79
- *
80
- * Memory comparison for 500 PDFs averaging 5MB each:
81
- * - parseDuc: files field holds 2.5GB of ArrayBuffer data in JS heap
82
- * - parseDucLazy: ~100KB of metadata + the original buffer (referenced, not copied)
83
- *
84
- * @param buffer - The raw .duc file bytes (from storage/IndexedDB/filesystem)
85
- * @param restoreConfig - Optional restore configuration
11
+ * 1. Read file bytes
12
+ * 2. WASM parse (SQLite Rust JS via serde-wasm-bindgen)
13
+ * 3. Element fixups (stack element flattening)
14
+ * 4. restore() for defaults & migrations
15
+ */
16
+ export declare function parseDuc(blob: Blob | File, _fileHandle?: FileSystemFileHandle | null, elementsConfig?: ElementsConfig, restoreConfig?: RestoreConfig): Promise<RestoredDataState>;
17
+ /**
18
+ * Parse a `.duc` file lazily returns everything EXCEPT external file data blobs.
19
+ * Use `LazyExternalFileStore` for on-demand file access.
86
20
  */
87
- export declare const parseDucLazy: (buffer: Uint8Array, restoreConfig?: RestoreConfig) => Promise<LazyRestoredDataState>;
21
+ export declare function parseDucLazy(buffer: Uint8Array, elementsConfig?: ElementsConfig, restoreConfig?: RestoreConfig): Promise<LazyRestoredDataState>;