ducjs 2.0.0 → 2.1.0

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 (248) hide show
  1. package/README.md +1 -1
  2. package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +0 -3
  3. package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +0 -8
  4. package/dist/flatbuffers/duc/duc-leader-style.d.ts +0 -3
  5. package/dist/flatbuffers/duc/duc-leader-style.js +0 -8
  6. package/dist/flatbuffers/duc/duc-plot-style.d.ts +1 -4
  7. package/dist/flatbuffers/duc/duc-plot-style.js +1 -10
  8. package/dist/flatbuffers/duc/duc-table-style.d.ts +0 -3
  9. package/dist/flatbuffers/duc/duc-table-style.js +0 -8
  10. package/dist/flatbuffers/duc/duc-text-style.d.ts +0 -3
  11. package/dist/flatbuffers/duc/duc-text-style.js +0 -8
  12. package/dist/flatbuffers/duc/duc-viewport-style.d.ts +1 -4
  13. package/dist/flatbuffers/duc/duc-viewport-style.js +1 -10
  14. package/dist/flatbuffers/duc/duc-xray-style.d.ts +1 -4
  15. package/dist/flatbuffers/duc/duc-xray-style.js +1 -10
  16. package/dist/flatbuffers/duc/exported-data-state.d.ts +3 -0
  17. package/dist/flatbuffers/duc/exported-data-state.js +8 -1
  18. package/dist/index.d.ts +0 -1
  19. package/dist/index.js +0 -1
  20. package/dist/parse.d.ts +5 -5
  21. package/dist/parse.js +57 -20
  22. package/dist/restore/restoreDataState.d.ts +14 -10
  23. package/dist/restore/restoreDataState.js +29 -22
  24. package/dist/restore/restoreElements.d.ts +2 -2
  25. package/dist/restore/restoreElements.js +21 -14
  26. package/dist/restore/restoreStandards.d.ts +2 -2
  27. package/dist/restore/restoreStandards.js +4 -4
  28. package/dist/serialize.d.ts +3 -2
  29. package/dist/serialize.js +14 -27
  30. package/dist/technical/measurements.d.ts +2 -2
  31. package/dist/technical/measurements.js +1 -1
  32. package/dist/technical/scopes.d.ts +4 -4
  33. package/dist/technical/scopes.js +1 -1
  34. package/dist/technical/standards.d.ts +4 -4
  35. package/dist/types/elements/index.d.ts +13 -13
  36. package/dist/types/elements/typeChecks.d.ts +5 -4
  37. package/dist/types/elements/typeChecks.js +5 -2
  38. package/dist/types/geometryTypes.d.ts +2 -2
  39. package/dist/types/index.d.ts +11 -8
  40. package/dist/types/index.js +1 -0
  41. package/dist/types/typeChecks.d.ts +5 -0
  42. package/dist/types/typeChecks.js +10 -0
  43. package/dist/utils/bounds.d.ts +3 -3
  44. package/dist/utils/bounds.js +3 -3
  45. package/dist/utils/constants.d.ts +5 -3
  46. package/dist/utils/constants.js +3 -5
  47. package/dist/utils/elements/frameElement.d.ts +2 -1
  48. package/dist/utils/elements/frameElement.js +13 -1
  49. package/dist/utils/elements/freedrawElement.d.ts +1 -1
  50. package/dist/utils/elements/freedrawElement.js +1 -1
  51. package/dist/utils/elements/index.d.ts +4 -4
  52. package/dist/utils/elements/index.js +17 -21
  53. package/dist/utils/elements/linearElement.d.ts +6 -6
  54. package/dist/utils/elements/linearElement.js +4 -4
  55. package/dist/utils/elements/newElement.d.ts +3 -3
  56. package/dist/utils/elements/newElement.js +26 -26
  57. package/dist/utils/elements/textElement.d.ts +7 -7
  58. package/dist/utils/elements/textElement.js +11 -9
  59. package/dist/utils/elements/viewportElement.d.ts +1 -1
  60. package/dist/utils/functionCodec.js +2 -2
  61. package/dist/utils/index.d.ts +1 -0
  62. package/dist/utils/index.js +1 -0
  63. package/dist/utils/math/algebra/gadirections.d.ts +1 -1
  64. package/dist/utils/math/algebra/gadirections.js +1 -1
  65. package/dist/utils/math/algebra/galines.d.ts +1 -1
  66. package/dist/utils/math/algebra/galines.js +1 -1
  67. package/dist/utils/math/algebra/gapoints.d.ts +1 -1
  68. package/dist/utils/math/algebra/gapoints.js +3 -3
  69. package/dist/utils/math/algebra/gatransforms.d.ts +1 -1
  70. package/dist/utils/math/algebra/gatransforms.js +2 -2
  71. package/dist/utils/math/bbox.d.ts +2 -2
  72. package/dist/utils/math/geometry.d.ts +3 -3
  73. package/dist/utils/math/geometry.js +2 -2
  74. package/dist/utils/math/index.d.ts +6 -6
  75. package/dist/utils/math/index.js +3 -3
  76. package/dist/utils/normalize.d.ts +2 -2
  77. package/dist/utils/normalize.js +2 -2
  78. package/dist/utils/shape.d.ts +2 -2
  79. package/dist/utils/shape.js +8 -8
  80. package/dist/utils/state/grid.d.ts +1 -1
  81. package/dist/utils/state/grid.js +3 -3
  82. package/dist/utils/state/index.d.ts +1 -1
  83. package/dist/utils/state/index.js +7 -7
  84. package/dist/utils/traverse.d.ts +22 -0
  85. package/dist/utils/traverse.js +87 -0
  86. package/dist/utils/version.d.ts +1 -1
  87. package/dist/utils/version.js +1 -1
  88. package/package.json +4 -2
  89. package/dist/legacy/index.d.ts +0 -1
  90. package/dist/legacy/index.js +0 -1
  91. package/dist/legacy/v1/duc/app-state.d.ts +0 -124
  92. package/dist/legacy/v1/duc/app-state.js +0 -388
  93. package/dist/legacy/v1/duc/binary-file-data.d.ts +0 -27
  94. package/dist/legacy/v1/duc/binary-file-data.js +0 -90
  95. package/dist/legacy/v1/duc/binary-files-entry.d.ts +0 -16
  96. package/dist/legacy/v1/duc/binary-files-entry.js +0 -43
  97. package/dist/legacy/v1/duc/binary-files.d.ts +0 -17
  98. package/dist/legacy/v1/duc/binary-files.js +0 -55
  99. package/dist/legacy/v1/duc/binding-point.d.ts +0 -15
  100. package/dist/legacy/v1/duc/binding-point.js +0 -48
  101. package/dist/legacy/v1/duc/bound-element.d.ts +0 -17
  102. package/dist/legacy/v1/duc/bound-element.js +0 -48
  103. package/dist/legacy/v1/duc/duc-block-attribute-details.d.ts +0 -22
  104. package/dist/legacy/v1/duc/duc-block-attribute-details.js +0 -57
  105. package/dist/legacy/v1/duc/duc-block-attribute.d.ts +0 -16
  106. package/dist/legacy/v1/duc/duc-block-attribute.js +0 -43
  107. package/dist/legacy/v1/duc/duc-block-instance-element-override.d.ts +0 -17
  108. package/dist/legacy/v1/duc/duc-block-instance-element-override.js +0 -48
  109. package/dist/legacy/v1/duc/duc-block.d.ts +0 -34
  110. package/dist/legacy/v1/duc/duc-block.js +0 -110
  111. package/dist/legacy/v1/duc/duc-element.d.ts +0 -273
  112. package/dist/legacy/v1/duc/duc-element.js +0 -865
  113. package/dist/legacy/v1/duc/duc-group.d.ts +0 -40
  114. package/dist/legacy/v1/duc/duc-group.js +0 -114
  115. package/dist/legacy/v1/duc/duc-line-reference.d.ts +0 -15
  116. package/dist/legacy/v1/duc/duc-line-reference.js +0 -43
  117. package/dist/legacy/v1/duc/duc-line.d.ts +0 -15
  118. package/dist/legacy/v1/duc/duc-line.js +0 -43
  119. package/dist/legacy/v1/duc/duc-path.d.ts +0 -26
  120. package/dist/legacy/v1/duc/duc-path.js +0 -69
  121. package/dist/legacy/v1/duc/duc-table-cell.d.ts +0 -22
  122. package/dist/legacy/v1/duc/duc-table-cell.js +0 -57
  123. package/dist/legacy/v1/duc/duc-table-column.d.ts +0 -18
  124. package/dist/legacy/v1/duc/duc-table-column.js +0 -50
  125. package/dist/legacy/v1/duc/duc-table-row.d.ts +0 -18
  126. package/dist/legacy/v1/duc/duc-table-row.js +0 -50
  127. package/dist/legacy/v1/duc/duc-table-style-props.d.ts +0 -39
  128. package/dist/legacy/v1/duc/duc-table-style-props.js +0 -114
  129. package/dist/legacy/v1/duc/duc-table-style.d.ts +0 -14
  130. package/dist/legacy/v1/duc/duc-table-style.js +0 -41
  131. package/dist/legacy/v1/duc/element-background.d.ts +0 -14
  132. package/dist/legacy/v1/duc/element-background.js +0 -41
  133. package/dist/legacy/v1/duc/element-content-base.d.ts +0 -22
  134. package/dist/legacy/v1/duc/element-content-base.js +0 -64
  135. package/dist/legacy/v1/duc/element-stroke.d.ts +0 -23
  136. package/dist/legacy/v1/duc/element-stroke.js +0 -66
  137. package/dist/legacy/v1/duc/exported-data-state.d.ts +0 -51
  138. package/dist/legacy/v1/duc/exported-data-state.js +0 -155
  139. package/dist/legacy/v1/duc/image-crop.d.ts +0 -23
  140. package/dist/legacy/v1/duc/image-crop.js +0 -80
  141. package/dist/legacy/v1/duc/linear-element-editor.d.ts +0 -44
  142. package/dist/legacy/v1/duc/linear-element-editor.js +0 -119
  143. package/dist/legacy/v1/duc/point-binding.d.ts +0 -25
  144. package/dist/legacy/v1/duc/point-binding.js +0 -72
  145. package/dist/legacy/v1/duc/point.d.ts +0 -20
  146. package/dist/legacy/v1/duc/point.js +0 -63
  147. package/dist/legacy/v1/duc/pointer-down-state.d.ts +0 -32
  148. package/dist/legacy/v1/duc/pointer-down-state.js +0 -90
  149. package/dist/legacy/v1/duc/renderer-state.d.ts +0 -17
  150. package/dist/legacy/v1/duc/renderer-state.js +0 -54
  151. package/dist/legacy/v1/duc/segment-midpoint-state.d.ts +0 -18
  152. package/dist/legacy/v1/duc/segment-midpoint-state.js +0 -57
  153. package/dist/legacy/v1/duc/simple-point.d.ts +0 -15
  154. package/dist/legacy/v1/duc/simple-point.js +0 -48
  155. package/dist/legacy/v1/duc/stroke-sides.d.ts +0 -23
  156. package/dist/legacy/v1/duc/stroke-sides.js +0 -66
  157. package/dist/legacy/v1/duc/stroke-style.d.ts +0 -31
  158. package/dist/legacy/v1/duc/stroke-style.js +0 -102
  159. package/dist/legacy/v1/duc/tiling-properties.d.ts +0 -21
  160. package/dist/legacy/v1/duc/tiling-properties.js +0 -75
  161. package/dist/legacy/v1/duc.d.ts +0 -35
  162. package/dist/legacy/v1/duc.js +0 -37
  163. package/dist/legacy/v1/index.d.ts +0 -1
  164. package/dist/legacy/v1/index.js +0 -1
  165. package/dist/legacy/v1/parse/index.d.ts +0 -67
  166. package/dist/legacy/v1/parse/index.js +0 -101
  167. package/dist/legacy/v1/parse/parseAppStateFromBinary.d.ts +0 -3
  168. package/dist/legacy/v1/parse/parseAppStateFromBinary.js +0 -139
  169. package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.d.ts +0 -4
  170. package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.js +0 -32
  171. package/dist/legacy/v1/parse/parseBlockFromBinary.d.ts +0 -3
  172. package/dist/legacy/v1/parse/parseBlockFromBinary.js +0 -70
  173. package/dist/legacy/v1/parse/parseElementFromBinary.d.ts +0 -8
  174. package/dist/legacy/v1/parse/parseElementFromBinary.js +0 -387
  175. package/dist/legacy/v1/parse/parseGroupFromBinary.d.ts +0 -4
  176. package/dist/legacy/v1/parse/parseGroupFromBinary.js +0 -36
  177. package/dist/legacy/v1/parse/parseRendererStateFromBinary.d.ts +0 -4
  178. package/dist/legacy/v1/parse/parseRendererStateFromBinary.js +0 -15
  179. package/dist/legacy/v1/serialize/index.d.ts +0 -5
  180. package/dist/legacy/v1/serialize/index.js +0 -81
  181. package/dist/legacy/v1/serialize/serializationUtils.d.ts +0 -17
  182. package/dist/legacy/v1/serialize/serializationUtils.js +0 -27
  183. package/dist/legacy/v1/serialize/serializeAppStateFromDuc.d.ts +0 -4
  184. package/dist/legacy/v1/serialize/serializeAppStateFromDuc.js +0 -145
  185. package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.d.ts +0 -4
  186. package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.js +0 -46
  187. package/dist/legacy/v1/serialize/serializeBlockFromDuc.d.ts +0 -3
  188. package/dist/legacy/v1/serialize/serializeBlockFromDuc.js +0 -60
  189. package/dist/legacy/v1/serialize/serializeElementFromDuc.d.ts +0 -8
  190. package/dist/legacy/v1/serialize/serializeElementFromDuc.js +0 -435
  191. package/dist/legacy/v1/serialize/serializeGroupFromDuc.d.ts +0 -3
  192. package/dist/legacy/v1/serialize/serializeGroupFromDuc.js +0 -37
  193. package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.d.ts +0 -4
  194. package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.js +0 -7
  195. package/dist/legacy/v1/types/elements/index.d.ts +0 -480
  196. package/dist/legacy/v1/types/elements/index.js +0 -1
  197. package/dist/legacy/v1/types/elements/typeChecks.d.ts +0 -40
  198. package/dist/legacy/v1/types/elements/typeChecks.js +0 -179
  199. package/dist/legacy/v1/types/geometryTypes.d.ts +0 -78
  200. package/dist/legacy/v1/types/geometryTypes.js +0 -1
  201. package/dist/legacy/v1/types/index.d.ts +0 -496
  202. package/dist/legacy/v1/types/index.js +0 -1
  203. package/dist/legacy/v1/types/utility-types.d.ts +0 -31
  204. package/dist/legacy/v1/types/utility-types.js +0 -1
  205. package/dist/legacy/v1/utils/bounds.d.ts +0 -76
  206. package/dist/legacy/v1/utils/bounds.js +0 -415
  207. package/dist/legacy/v1/utils/constants.d.ts +0 -370
  208. package/dist/legacy/v1/utils/constants.js +0 -571
  209. package/dist/legacy/v1/utils/elements/index.d.ts +0 -26
  210. package/dist/legacy/v1/utils/elements/index.js +0 -108
  211. package/dist/legacy/v1/utils/elements/linearElement.d.ts +0 -133
  212. package/dist/legacy/v1/utils/elements/linearElement.js +0 -544
  213. package/dist/legacy/v1/utils/elements/textElement.d.ts +0 -89
  214. package/dist/legacy/v1/utils/elements/textElement.js +0 -563
  215. package/dist/legacy/v1/utils/index.d.ts +0 -26
  216. package/dist/legacy/v1/utils/index.js +0 -40
  217. package/dist/legacy/v1/utils/math/algebra/ga.d.ts +0 -63
  218. package/dist/legacy/v1/utils/math/algebra/ga.js +0 -268
  219. package/dist/legacy/v1/utils/math/algebra/gadirections.d.ts +0 -9
  220. package/dist/legacy/v1/utils/math/algebra/gadirections.js +0 -18
  221. package/dist/legacy/v1/utils/math/algebra/galines.d.ts +0 -23
  222. package/dist/legacy/v1/utils/math/algebra/galines.js +0 -32
  223. package/dist/legacy/v1/utils/math/algebra/gapoints.d.ts +0 -8
  224. package/dist/legacy/v1/utils/math/algebra/gapoints.js +0 -30
  225. package/dist/legacy/v1/utils/math/algebra/gatransforms.d.ts +0 -10
  226. package/dist/legacy/v1/utils/math/algebra/gatransforms.js +0 -23
  227. package/dist/legacy/v1/utils/math/bbox.d.ts +0 -10
  228. package/dist/legacy/v1/utils/math/bbox.js +0 -42
  229. package/dist/legacy/v1/utils/math/geometry.d.ts +0 -102
  230. package/dist/legacy/v1/utils/math/geometry.js +0 -790
  231. package/dist/legacy/v1/utils/math/index.d.ts +0 -309
  232. package/dist/legacy/v1/utils/math/index.js +0 -1140
  233. package/dist/legacy/v1/utils/math/random.d.ts +0 -4
  234. package/dist/legacy/v1/utils/math/random.js +0 -25
  235. package/dist/legacy/v1/utils/measurements.d.ts +0 -33
  236. package/dist/legacy/v1/utils/measurements.js +0 -65
  237. package/dist/legacy/v1/utils/normalize.d.ts +0 -14
  238. package/dist/legacy/v1/utils/normalize.js +0 -49
  239. package/dist/legacy/v1/utils/restore.d.ts +0 -197
  240. package/dist/legacy/v1/utils/restore.js +0 -1255
  241. package/dist/legacy/v1/utils/scopes.d.ts +0 -260
  242. package/dist/legacy/v1/utils/scopes.js +0 -661
  243. package/dist/legacy/v1/utils/standards.d.ts +0 -12
  244. package/dist/legacy/v1/utils/standards.js +0 -10
  245. package/dist/legacy/v1/utils/state/index.d.ts +0 -2
  246. package/dist/legacy/v1/utils/state/index.js +0 -68
  247. package/dist/legacy/v1/utils/url.d.ts +0 -8
  248. package/dist/legacy/v1/utils/url.js +0 -33
@@ -1,13 +1,14 @@
1
1
  export * from "./elements";
2
2
  export * from "./geometryTypes";
3
3
  export * from "./utility-types";
4
- import { OBJECT_SNAP_MODE, PRUNING_LEVEL } from "ducjs/flatbuffers/duc";
5
- import { SupportedMeasures } from "ducjs/technical/scopes";
6
- import { Standard } from "ducjs/technical/standards";
7
- import { DucBindableElement, DucBlock, DucElement, DucElementType, DucGroup, DucIframeLikeElement, DucLayer, DucLinearElement, DucPoint, DucRegion, DucTextElement, ElementBackground, ElementStroke, ExternalFileId, FontFamilyValues, LineHead, NonDeleted, TextAlign } from "ducjs/types/elements";
8
- import { GeometricPoint, Percentage, Radian, ScaleFactor } from "ducjs/types/geometryTypes";
9
- import { MakeBrand, MaybePromise, ValueOf } from "ducjs/types/utility-types";
10
- import type { GRID_DISPLAY_TYPE, GRID_TYPE, SNAP_MARKER_SHAPE, SNAP_MODE, SNAP_OVERRIDE_BEHAVIOR } from "ducjs/utils/constants";
4
+ export * from "./typeChecks";
5
+ import { OBJECT_SNAP_MODE, PRUNING_LEVEL } from "../flatbuffers/duc";
6
+ import { SupportedMeasures } from "../technical/scopes";
7
+ import { Standard } from "../technical/standards";
8
+ import { DucBindableElement, DucBlock, DucElement, DucElementType, DucGroup, DucIframeLikeElement, DucLayer, DucLinearElement, DucPoint, DucRegion, DucTextElement, ElementBackground, ElementStroke, ExternalFileId, FontFamilyValues, LineHead, NonDeleted, TextAlign } from "./elements";
9
+ import { GeometricPoint, Percentage, Radian, ScaleFactor } from "./geometryTypes";
10
+ import { MakeBrand, MaybePromise, ValueOf } from "./utility-types";
11
+ import type { GRID_DISPLAY_TYPE, GRID_TYPE, SNAP_MARKER_SHAPE, SNAP_MODE, SNAP_OVERRIDE_BEHAVIOR } from "../utils/constants";
11
12
  /**
12
13
  * Root data structure for the stored data state
13
14
  */
@@ -30,6 +31,8 @@ export interface ExportedDataState {
30
31
  files: DucExternalFiles | undefined;
31
32
  /** In case it is needed to embed the version control into the file format */
32
33
  versionGraph: VersionGraph | undefined;
34
+ /** Actual file id */
35
+ id: string | undefined;
33
36
  }
34
37
  export type ExportedDataStateContent = Omit<ExportedDataState, "type" | "version" | "source">;
35
38
  /**
@@ -106,7 +109,7 @@ export type SuggestedPointBinding = [
106
109
  "start" | "end" | "both",
107
110
  NonDeleted<DucBindableElement>
108
111
  ];
109
- export type ToolType = "selection" | "rectangle" | "polygon" | "ellipse" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "embeddable" | "ruler" | "lasso" | "laser" | "table";
112
+ export type ToolType = "selection" | "rectangle" | "polygon" | "ellipse" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "plot" | "embeddable" | "ruler" | "lasso" | "laser" | "table";
110
113
  export type ElementOrToolType = DucElementType | ToolType | "custom";
111
114
  /**
112
115
  * Defines the global, persistent settings for the drawing. These are fundamental
@@ -1,3 +1,4 @@
1
1
  export * from "./elements";
2
2
  export * from "./geometryTypes";
3
3
  export * from "./utility-types";
4
+ export * from "./typeChecks";
@@ -0,0 +1,5 @@
1
+ import { PrecisionValue } from ".";
2
+ /**
3
+ * Type guard to check if an object is a PrecisionValue
4
+ */
5
+ export declare const isPrecisionValue: (obj: any) => obj is PrecisionValue;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Type guard to check if an object is a PrecisionValue
3
+ */
4
+ export const isPrecisionValue = (obj) => {
5
+ return obj !== null &&
6
+ typeof obj === 'object' &&
7
+ typeof obj.value === 'number' &&
8
+ typeof obj.scoped === 'number' &&
9
+ Object.keys(obj).length === 2;
10
+ };
@@ -1,6 +1,6 @@
1
- import { Scope, ScopedValue } from "ducjs/types";
2
- import { DucElement, DucFreeDrawElement, DucLine, DucLinearElement, DucPoint, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap } from "ducjs/types/elements";
3
- import { Bounds, GeometricPoint } from "ducjs/types/geometryTypes";
1
+ import { Scope, ScopedValue } from "../types";
2
+ import { DucElement, DucFreeDrawElement, DucLine, DucLinearElement, DucPoint, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap } from "../types/elements";
3
+ import { Bounds, GeometricPoint } from "../types/geometryTypes";
4
4
  type SV = ScopedValue;
5
5
  /**
6
6
  * Common bounds calculation interface
@@ -1,6 +1,6 @@
1
- import { isArrowElement, isFreeDrawElement, isLinearElement, isTextElement } from "ducjs/types/elements/typeChecks";
2
- import { getBoundTextElementPosition, getLinearElementAbsoluteCoords } from "ducjs/utils/elements/linearElement";
3
- import { getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, rescaleLines, rescalePoints, rotate } from "ducjs/utils/math";
1
+ import { isArrowElement, isFreeDrawElement, isLinearElement, isTextElement } from "../types/elements/typeChecks";
2
+ import { getBoundTextElementPosition, getLinearElementAbsoluteCoords } from "./elements/linearElement";
3
+ import { getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, rescaleLines, rescalePoints, rotate } from "./math";
4
4
  export const getElementAbsoluteCoords = (element, elementsMap, currentScope, includeBoundText = false, returnUnrotatedBoundsOnly = true) => {
5
5
  if (isFreeDrawElement(element)) {
6
6
  return getFreeDrawElementAbsoluteCoords(element);
@@ -1,6 +1,6 @@
1
- import { GridSettings, RawValue, SnapSettings } from "ducjs/types";
2
- import { DucElement, DucEllipseElement, DucFreeDrawElement, DucTextElement, ElementBackground, ElementStroke, FontFamilyValues } from "ducjs/types/elements";
3
- import { MAX_ZOOM, MIN_ZOOM } from "ducjs/technical/scopes";
1
+ import { GridSettings, RawValue, SnapSettings } from "../types";
2
+ import { DucElement, DucEllipseElement, DucFreeDrawElement, DucTextElement, ElementBackground, ElementStroke, FontFamilyValues } from "../types/elements";
3
+ import { MAX_ZOOM, MIN_ZOOM } from "../technical/scopes";
4
4
  export declare const COLOR_PALETTE: {
5
5
  readonly transparent: "transparent";
6
6
  readonly black: "#1e1e1e";
@@ -47,6 +47,8 @@ export declare const MIME_TYPES: {
47
47
  readonly "excalidraw.svg": "image/svg+xml";
48
48
  readonly "excalidraw.png": "image/png";
49
49
  readonly binary: "application/octet-stream";
50
+ readonly pdf: "application/pdf";
51
+ readonly zip: "application/zip";
50
52
  };
51
53
  export declare const EXPORT_IMAGE_TYPES: {
52
54
  readonly png: "png";
@@ -1,5 +1,5 @@
1
- import { ELEMENT_CONTENT_PREFERENCE, OBJECT_SNAP_MODE, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN } from "ducjs/flatbuffers/duc";
2
- import { MAX_ZOOM, MIN_ZOOM, NEUTRAL_SCOPE } from "ducjs/technical/scopes";
1
+ import { ELEMENT_CONTENT_PREFERENCE, OBJECT_SNAP_MODE, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN } from "../flatbuffers/duc";
2
+ import { MAX_ZOOM, MIN_ZOOM, NEUTRAL_SCOPE } from "../technical/scopes";
3
3
  export const COLOR_PALETTE = {
4
4
  transparent: "transparent",
5
5
  black: "#1e1e1e",
@@ -37,9 +37,7 @@ export const MIME_TYPES = Object.assign({ json: "application/json",
37
37
  // excalidraw data
38
38
  duc: "application/vnd.duc-cad", ducfig: "application/vnd.duc-config", excalidrawlib: "application/vnd.excalidrawlib+json",
39
39
  // image-encoded excalidraw data
40
- "excalidraw.svg": "image/svg+xml", "excalidraw.png": "image/png",
41
- // binary
42
- binary: "application/octet-stream" }, IMAGE_MIME_TYPES);
40
+ "excalidraw.svg": "image/svg+xml", "excalidraw.png": "image/png", binary: "application/octet-stream", pdf: "application/pdf", zip: "application/zip" }, IMAGE_MIME_TYPES);
43
41
  export const EXPORT_IMAGE_TYPES = {
44
42
  png: "png",
45
43
  svg: "svg",
@@ -1,4 +1,5 @@
1
- import { DucElement, DucElementsIncludingDeleted, DucFrameLikeElement, ElementsMap } from "ducjs/types/elements";
1
+ import { DucElement, DucElementsIncludingDeleted, DucFrameLikeElement, ElementsMap } from "../../types/elements";
2
2
  export declare const getContainingFrame: (element: DucElement, elementsMap: ElementsMap) => DucFrameLikeElement | null;
3
3
  export declare const getFrameLikeElements: (allElements: DucElementsIncludingDeleted) => DucFrameLikeElement[];
4
+ export declare const canFrameLikeContainElement: (frame: DucFrameLikeElement, element: DucElement) => boolean;
4
5
  export declare const getFrameLikeTitle: (element: DucFrameLikeElement) => string;
@@ -1,4 +1,4 @@
1
- import { isFrameLikeElement } from "ducjs/types/elements/typeChecks";
1
+ import { isFrameElement, isFrameLikeElement, isPlotElement } from "../../types/elements/typeChecks";
2
2
  export const getContainingFrame = (element, elementsMap) => {
3
3
  if (!element.frameId) {
4
4
  return null;
@@ -9,6 +9,18 @@ export const getContainingFrame = (element, elementsMap) => {
9
9
  export const getFrameLikeElements = (allElements) => {
10
10
  return allElements.filter((element) => isFrameLikeElement(element));
11
11
  };
12
+ export const canFrameLikeContainElement = (frame, element) => {
13
+ if (frame.id === element.id) {
14
+ return false;
15
+ }
16
+ if (isPlotElement(element)) {
17
+ return false;
18
+ }
19
+ if (isFrameElement(element)) {
20
+ return frame.type === "plot";
21
+ }
22
+ return true;
23
+ };
12
24
  export const getFrameLikeTitle = (element) => {
13
25
  return element.label === null
14
26
  ? "Frame"
@@ -1,2 +1,2 @@
1
- import { DucFreeDrawElement } from "ducjs/types/elements";
1
+ import { DucFreeDrawElement } from "../../types/elements";
2
2
  export declare function getFreeDrawSvgPath(element: DucFreeDrawElement): string;
@@ -1,4 +1,4 @@
1
- import { med } from "ducjs/utils/math";
1
+ import { med } from "../math";
2
2
  import { getStroke } from "perfect-freehand";
3
3
  // Trim SVG path data so number are each two decimal points. This
4
4
  // improves SVG exports, and prevents rendering errors on points
@@ -4,10 +4,10 @@ export * from "./linearElement";
4
4
  export * from "./textElement";
5
5
  export * from "./frameElement";
6
6
  export * from "./viewportElement";
7
- import { Scope } from "ducjs/types";
8
- import { _DucStackBase, DucElement, DucNonSelectionElement, DucTableElement, DucTextStyle, ElementConstructorOpts, NonDeleted } from "ducjs/types/elements";
9
- import { GeometricPoint, TuplePoint } from "ducjs/types/geometryTypes";
10
- import { Mutable } from "ducjs/types/utility-types";
7
+ import { Scope } from "../../types";
8
+ import { _DucStackBase, DucElement, DucNonSelectionElement, DucTableElement, DucTextStyle, ElementConstructorOpts, NonDeleted } from "../../types/elements";
9
+ import { GeometricPoint, TuplePoint } from "../../types/geometryTypes";
10
+ import { Mutable } from "../../types/utility-types";
11
11
  /**
12
12
  * Returns a default DucTextStyle object for the given scope.
13
13
  */
@@ -4,24 +4,17 @@ export * from "./linearElement";
4
4
  export * from "./textElement";
5
5
  export * from "./frameElement";
6
6
  export * from "./viewportElement";
7
- import { LINE_SPACING_TYPE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION } from "ducjs/flatbuffers/duc";
8
- import { isFreeDrawElement, isLinearElement } from "ducjs/types/elements/typeChecks";
9
- import { getUpdatedTimestamp } from "ducjs/utils";
10
- import { DEFAULT_ELEMENT_PROPS, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, FONT_FAMILY } from "ducjs/utils/constants";
11
- import { randomInteger } from "ducjs/utils/math/random";
12
- import { getPrecisionValueFromRaw } from "ducjs/technical/scopes";
7
+ import { LINE_SPACING_TYPE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION } from "../../flatbuffers/duc";
8
+ import { isFreeDrawElement, isLinearElement } from "../../types/elements/typeChecks";
9
+ import { getUpdatedTimestamp } from "..";
10
+ import { DEFAULT_ELEMENT_PROPS, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, FONT_FAMILY } from "../constants";
11
+ import { randomInteger } from "../math/random";
12
+ import { getPrecisionValueFromRaw } from "../../technical/scopes";
13
13
  /**
14
14
  * Returns a default DucTextStyle object for the given scope.
15
15
  */
16
16
  export function getDefaultTextStyle(currentScope) {
17
17
  return {
18
- roundness: DEFAULT_ELEMENT_PROPS.roundness,
19
- blending: undefined,
20
- strokeColor: undefined,
21
- backgroundColor: undefined,
22
- background: [DEFAULT_ELEMENT_PROPS.background],
23
- stroke: [DEFAULT_ELEMENT_PROPS.stroke],
24
- opacity: DEFAULT_ELEMENT_PROPS.opacity,
25
18
  isLtr: true,
26
19
  fontFamily: DEFAULT_FONT_FAMILY,
27
20
  bigFontFamily: "sans-serif",
@@ -83,7 +76,12 @@ export const getDefaultTableData = (currentScope) => {
83
76
  // A practical starting column width
84
77
  const defaultColumnWidth = getPrecisionValueFromRaw(140, currentScope, currentScope);
85
78
  // Base/default styling for cells
86
- const baseCellStyle = Object.assign(Object.assign({}, DEFAULT_ELEMENT_PROPS), { background: [DEFAULT_ELEMENT_PROPS.background], stroke: [DEFAULT_ELEMENT_PROPS.stroke], textStyle: {
79
+ const baseCellStyle = {
80
+ stroke: [DEFAULT_ELEMENT_PROPS.stroke],
81
+ background: [DEFAULT_ELEMENT_PROPS.background],
82
+ roundness: DEFAULT_ELEMENT_PROPS.roundness,
83
+ opacity: DEFAULT_ELEMENT_PROPS.opacity,
84
+ textStyle: {
87
85
  isLtr: true,
88
86
  fontFamily: FONT_FAMILY.Virgil,
89
87
  bigFontFamily: "sans-serif",
@@ -97,18 +95,16 @@ export const getDefaultTableData = (currentScope) => {
97
95
  widthFactor: 1,
98
96
  isUpsideDown: false,
99
97
  isBackwards: false,
100
- roundness: DEFAULT_ELEMENT_PROPS.roundness,
101
- background: [DEFAULT_ELEMENT_PROPS.background],
102
- stroke: [DEFAULT_ELEMENT_PROPS.stroke],
103
- opacity: DEFAULT_ELEMENT_PROPS.opacity,
104
- }, margins: {
98
+ },
99
+ margins: {
105
100
  top: vMargin,
106
101
  right: hMargin,
107
102
  bottom: vMargin,
108
103
  left: hMargin,
109
- },
104
+ },
110
105
  // Left + middle is a great general-purpose default for tables
111
- alignment: TABLE_CELL_ALIGNMENT.MIDDLE_LEFT });
106
+ alignment: TABLE_CELL_ALIGNMENT.MIDDLE_LEFT,
107
+ };
112
108
  // Create default columns
113
109
  const columns = Object.fromEntries(columnIds.map((id) => [id, { id, width: defaultColumnWidth }]));
114
110
  // Create default rows (taller header row)
@@ -1,9 +1,9 @@
1
- import { HANDLE_TYPE } from "ducjs/flatbuffers/duc";
2
- import type { PrecisionValue, RawValue, Scope } from "ducjs/types";
3
- import type { DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, DucTextElementWithContainer, ElementsMap, NonDeleted } from "ducjs/types/elements";
4
- import { Bounds, GeometricPoint } from "ducjs/types/geometryTypes";
5
- import type { ValueOf } from "ducjs/types/utility-types";
6
- import { ElementAbsoluteCoords } from "ducjs/utils/bounds";
1
+ import { HANDLE_TYPE } from "../../flatbuffers/duc";
2
+ import type { PrecisionValue, RawValue, Scope } from "../../types";
3
+ import type { DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, DucTextElementWithContainer, ElementsMap, NonDeleted } from "../../types/elements";
4
+ import { Bounds, GeometricPoint } from "../../types/geometryTypes";
5
+ import type { ValueOf } from "../../types/utility-types";
6
+ import { ElementAbsoluteCoords } from "../bounds";
7
7
  export type HandleType = ValueOf<typeof HANDLE_TYPE> | null;
8
8
  export type HandleInfo = {
9
9
  pointIndex: number;
@@ -1,7 +1,7 @@
1
- import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScopedBezierPointFromDucPoint } from "ducjs/technical/scopes";
2
- import { getBoundTextElement, getElementAbsoluteCoords, getElementPointsCoords } from "ducjs/utils/bounds";
3
- import { LINE_CONFIRM_THRESHOLD } from "ducjs/utils/constants";
4
- import { centerPoint, getBezierXY, getControlPointsForBezierCurve, getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, mapIntervalToBezierT, rotate, rotatePoint } from "ducjs/utils/math";
1
+ import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
2
+ import { getBoundTextElement, getElementAbsoluteCoords, getElementPointsCoords } from "../bounds";
3
+ import { LINE_CONFIRM_THRESHOLD } from "../constants";
4
+ import { centerPoint, getBezierXY, getControlPointsForBezierCurve, getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, mapIntervalToBezierT, rotate, rotatePoint } from "../math";
5
5
  /**
6
6
  * Merges overlapping points using the line-based system
7
7
  * Returns updated points and lines arrays
@@ -1,6 +1,6 @@
1
- import { Scope } from "ducjs/types";
2
- import { DucArrowElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement, DucParametricElement, DucPdfElement, DucPlotElement, DucPolygonElement, DucTableElement, DucTextElement, DucViewportElement, DucXRayElement, DucBlockInstanceElement, ElementConstructorOpts, ElementUpdate, NonDeleted } from "ducjs/types/elements";
3
- import { Mutable } from "ducjs/types/utility-types";
1
+ import { Scope } from "../../types";
2
+ import { DucArrowElement, DucBlockInstanceElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement, DucParametricElement, DucPdfElement, DucPlotElement, DucPolygonElement, DucTableElement, DucTextElement, DucViewportElement, DucXRayElement, ElementConstructorOpts, ElementUpdate, NonDeleted } from "../../types/elements";
3
+ import { Mutable } from "../../types/utility-types";
4
4
  export declare const newElementWith: <TElement extends DucElement>(element: TElement, updates: ElementUpdate<TElement>,
5
5
  /** pass `true` to always regenerate */
6
6
  force?: boolean) => TElement;
@@ -9,14 +9,14 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, IMAGE_STATUS, LINE_SPACING_TYPE, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, TEXT_FLOW_DIRECTION, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT, } from "ducjs/flatbuffers/duc";
13
- import { getUpdatedTimestamp, getZoom } from "ducjs/utils";
14
- import { DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, } from "ducjs/utils/constants";
15
- import { getDefaultStackProperties, getDefaultTableData, getDefaultTextStyle } from "ducjs/utils/elements";
16
- import { getFontString, getTextElementPositionOffsets, measureText, } from "ducjs/utils/elements/textElement";
17
- import { randomId, randomInteger } from "ducjs/utils/math/random";
18
- import { normalizeText } from "ducjs/utils/normalize";
19
- import { getPrecisionValueFromRaw } from "ducjs/technical/scopes";
12
+ import { getUpdatedTimestamp, getZoom } from "..";
13
+ import { BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, IMAGE_STATUS, LINE_SPACING_TYPE, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, TEXT_FLOW_DIRECTION, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "../../flatbuffers/duc";
14
+ import { getPrecisionValueFromRaw } from "../../technical/scopes";
15
+ import { DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN } from "../constants";
16
+ import { randomId, randomInteger } from "../math/random";
17
+ import { normalizeText } from "../normalize";
18
+ import { getDefaultStackProperties, getDefaultTableData, getDefaultTextStyle } from "./";
19
+ import { getFontString, getTextElementPositionOffsets, measureText, } from "./textElement";
20
20
  export const newElementWith = (element, updates,
21
21
  /** pass `true` to always regenerate */
22
22
  force = false) => {
@@ -81,18 +81,18 @@ export const newElement = (currentScope, opts) => _newElementBase(opts.type, cur
81
81
  export const newEmbeddableElement = (currentScope, opts) => {
82
82
  return Object.assign(Object.assign({}, opts), _newElementBase(opts.type, currentScope, opts));
83
83
  };
84
- export const newFrameElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign({}, _newElementBase("frame", currentScope, opts)), getDefaultStackProperties()), { type: "frame", clip: false, labelVisible: true, standardOverride: null }));
85
- export const newPlotElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign({}, _newElementBase("plot", currentScope, opts)), getDefaultStackProperties()), { type: "plot", clip: false, labelVisible: true, standardOverride: null, layout: {
84
+ export const newFrameElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true, standardOverride: null }), _newElementBase("frame", currentScope, opts)), { type: "frame" }));
85
+ export const newPlotElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true, standardOverride: null, layout: {
86
86
  margins: {
87
- top: getPrecisionValueFromRaw(25, currentScope, currentScope),
88
- right: getPrecisionValueFromRaw(25, currentScope, currentScope),
89
- bottom: getPrecisionValueFromRaw(25, currentScope, currentScope),
90
- left: getPrecisionValueFromRaw(25, currentScope, currentScope),
87
+ top: getPrecisionValueFromRaw(0, currentScope, currentScope),
88
+ right: getPrecisionValueFromRaw(0, currentScope, currentScope),
89
+ bottom: getPrecisionValueFromRaw(0, currentScope, currentScope),
90
+ left: getPrecisionValueFromRaw(0, currentScope, currentScope),
91
91
  }
92
- } }));
92
+ } }), _newElementBase("plot", currentScope, opts)), { type: "plot" }));
93
93
  export const newViewportElement = (currentScope, opts) => {
94
94
  var _a, _b, _c;
95
- return (Object.assign(Object.assign(Object.assign({}, _newElementBase("viewport", currentScope, opts)), getDefaultStackProperties()), { type: "viewport", points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, standardOverride: null, view: {
95
+ return (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, standardOverride: null, view: {
96
96
  scrollX: getPrecisionValueFromRaw(0, currentScope, currentScope),
97
97
  scrollY: getPrecisionValueFromRaw(0, currentScope, currentScope),
98
98
  zoom: getZoom((_a = opts.zoom) !== null && _a !== void 0 ? _a : 1, (_b = opts.mainScope) !== null && _b !== void 0 ? _b : currentScope, (_c = opts.scopeExponentThreshold) !== null && _c !== void 0 ? _c : 2),
@@ -102,7 +102,7 @@ export const newViewportElement = (currentScope, opts) => {
102
102
  y: getPrecisionValueFromRaw(0, currentScope, currentScope),
103
103
  },
104
104
  scope: currentScope,
105
- }, scale: 1, shadePlot: VIEWPORT_SHADE_PLOT.AS_DISPLAYED, frozenGroupIds: [], scaleIndicatorVisible: true }));
105
+ }, scale: 1, shadePlot: VIEWPORT_SHADE_PLOT.AS_DISPLAYED, frozenGroupIds: [], scaleIndicatorVisible: true }), _newElementBase("viewport", currentScope, opts)), { type: "viewport" }));
106
106
  };
107
107
  export const newEllipseElement = (currentScope, opts) => {
108
108
  return Object.assign(Object.assign({}, _newElementBase(opts.type, currentScope, opts)), { ratio: opts.ratio || DEFAULT_ELLIPSE_ELEMENT.ratio, startAngle: opts.startAngle || DEFAULT_ELLIPSE_ELEMENT.startAngle, endAngle: opts.endAngle || DEFAULT_ELLIPSE_ELEMENT.endAngle, showAuxCrosshair: opts.showAuxCrosshair || DEFAULT_ELLIPSE_ELEMENT.showAuxCrosshair });
@@ -155,19 +155,19 @@ export const newDocElement = (currentScope, opts) => {
155
155
  // DucDocStyle properties
156
156
  isLtr: (_b = opts.isLtr) !== null && _b !== void 0 ? _b : true, fontFamily: opts.fontFamily || DEFAULT_FONT_FAMILY, bigFontFamily: opts.bigFontFamily || "sans-serif", textAlign: opts.textAlign || DEFAULT_TEXT_ALIGN, verticalAlign: opts.verticalAlign || DEFAULT_VERTICAL_ALIGN, lineHeight: opts.lineHeight || 1.2, lineSpacing: opts.lineSpacing || { type: LINE_SPACING_TYPE.MULTIPLE, value: 1.2 }, obliqueAngle: opts.obliqueAngle || 0, fontSize: opts.fontSize || getPrecisionValueFromRaw(DEFAULT_FONT_SIZE, currentScope, currentScope), paperTextHeight: opts.paperTextHeight, widthFactor: opts.widthFactor || 1, isUpsideDown: (_c = opts.isUpsideDown) !== null && _c !== void 0 ? _c : false, isBackwards: (_d = opts.isBackwards) !== null && _d !== void 0 ? _d : false, paragraph: opts.paragraph || { firstLineIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), hangingIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), leftIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), rightIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceBefore: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceAfter: getPrecisionValueFromRaw(0, currentScope, currentScope), tabStops: [] }, stackFormat: opts.stackFormat || { autoStack: false, stackChars: [], properties: { upperScale: 0.7, lowerScale: 0.7, alignment: STACKED_TEXT_ALIGN.CENTER } } }));
157
157
  };
158
- export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("pdf", currentScope, opts)), { type: "pdf", fileId: null }));
159
- export const newMermaidElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("mermaid", currentScope, opts)), { type: "mermaid", source: "", theme: undefined, svgPath: null }));
160
- export const newXRayElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("xray", currentScope, opts)), { type: "xray", origin: { x: getPrecisionValueFromRaw(0, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, direction: { x: getPrecisionValueFromRaw(1, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, startFromOrigin: false, color: '#FF00FF' }));
158
+ export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
159
+ export const newMermaidElement = (currentScope, opts) => (Object.assign(Object.assign({ source: "", theme: undefined, svgPath: null }, _newElementBase("mermaid", currentScope, opts)), { type: "mermaid" }));
160
+ export const newXRayElement = (currentScope, opts) => (Object.assign(Object.assign({ origin: { x: getPrecisionValueFromRaw(0, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, direction: { x: getPrecisionValueFromRaw(1, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, startFromOrigin: false, color: '#FF00FF' }, _newElementBase("xray", currentScope, opts)), { type: "xray" }));
161
161
  export const newLeaderElement = (currentScope, opts) => {
162
162
  var _a, _b;
163
- return Object.assign(Object.assign({}, _newElementBase("leader", currentScope, opts)), { type: "leader", points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, headsOverride: undefined, dogleg: getPrecisionValueFromRaw(10, currentScope, currentScope), textStyle: opts.textStyle || getDefaultTextStyle(currentScope), textAttachment: opts.textAttachment || VERTICAL_ALIGN.TOP, blockAttachment: opts.blockAttachment || BLOCK_ATTACHMENT.CENTER_EXTENTS, leaderContent: (_a = opts.leaderContent) !== null && _a !== void 0 ? _a : null, contentAnchor: (_b = opts.contentAnchor) !== null && _b !== void 0 ? _b : {
163
+ return Object.assign(Object.assign({ points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, headsOverride: undefined, dogleg: getPrecisionValueFromRaw(10, currentScope, currentScope), textStyle: opts.textStyle || getDefaultTextStyle(currentScope), textAttachment: opts.textAttachment || VERTICAL_ALIGN.TOP, blockAttachment: opts.blockAttachment || BLOCK_ATTACHMENT.CENTER_EXTENTS, leaderContent: (_a = opts.leaderContent) !== null && _a !== void 0 ? _a : null, contentAnchor: (_b = opts.contentAnchor) !== null && _b !== void 0 ? _b : {
164
164
  x: 0,
165
165
  y: 0,
166
- } });
166
+ } }, _newElementBase("leader", currentScope, opts)), { type: "leader" });
167
167
  };
168
168
  export const newDimensionElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("dimension", currentScope, opts)), { type: 'dimension' }));
169
169
  export const newFeatureControlFrameElement = (currentScope, opts) => {
170
- return Object.assign(Object.assign({}, _newElementBase("featurecontrolframe", currentScope, opts)), { type: "featurecontrolframe", rows: [], leaderElementId: null, textStyle: getDefaultTextStyle(currentScope), layout: {
170
+ return Object.assign(Object.assign({ rows: [], leaderElementId: null, textStyle: getDefaultTextStyle(currentScope), layout: {
171
171
  padding: getPrecisionValueFromRaw(4, currentScope, currentScope),
172
172
  segmentSpacing: getPrecisionValueFromRaw(4, currentScope, currentScope),
173
173
  rowSpacing: getPrecisionValueFromRaw(2, currentScope, currentScope),
@@ -175,13 +175,13 @@ export const newFeatureControlFrameElement = (currentScope, opts) => {
175
175
  scale: 1,
176
176
  }, datumStyle: {
177
177
  bracketStyle: DATUM_BRACKET_STYLE.SQUARE
178
- } });
178
+ } }, _newElementBase("featurecontrolframe", currentScope, opts)), { type: "featurecontrolframe" });
179
179
  };
180
180
  export const newBlockInstanceElement = (currentScope, opts) => {
181
181
  var _a, _b, _c;
182
182
  return (Object.assign(Object.assign({}, _newElementBase("blockinstance", currentScope, opts)), { type: "blockinstance", blockId: opts.blockId, elementOverrides: (_a = opts.elementOverrides) !== null && _a !== void 0 ? _a : {}, attributeValues: (_b = opts.attributeValues) !== null && _b !== void 0 ? _b : {}, duplicationArray: (_c = opts.duplicationArray) !== null && _c !== void 0 ? _c : null }));
183
183
  };
184
- export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("parametric", currentScope, opts)), { type: 'parametric', source: { type: PARAMETRIC_SOURCE_TYPE.CODE, code: "" } }));
184
+ export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({ source: { type: PARAMETRIC_SOURCE_TYPE.CODE, code: "" } }, _newElementBase("parametric", currentScope, opts)), { type: 'parametric' }));
185
185
  // Simplified deep clone for the purpose of cloning DucElement.
186
186
  //
187
187
  // Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
@@ -202,7 +202,7 @@ const _deepCopyElement = (val, depth = 0) => {
202
202
  ? Object.create(Object.getPrototypeOf(val))
203
203
  : {};
204
204
  for (const key in val) {
205
- if (val.hasOwnProperty(key)) {
205
+ if (Object.prototype.hasOwnProperty.call(val, key)) {
206
206
  // don't copy non-serializable objects like these caches. They'll be
207
207
  // populated when the element is rendered.
208
208
  if (depth === 0 && (key === "shape" || key === "canvas")) {
@@ -1,9 +1,9 @@
1
- import { DucLocalState, RawValue, Scope, ScopedValue } from "ducjs/types";
2
- import { DucElement, DucElementType, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap, FontFamilyValues, FontString, NonDeletedDucElement } from "ducjs/types/elements";
3
- import { GeometricPoint } from "ducjs/types/geometryTypes";
4
- import { ExtractSetType } from "ducjs/types/utility-types";
5
- import { getBoundTextElementPosition } from "ducjs/utils/elements/linearElement";
6
- import { SupportedMeasures } from "ducjs/technical/scopes";
1
+ import { DucLocalState, RawValue, Scope, ScopedValue } from "../../types";
2
+ import { DucElement, DucElementType, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap, FontFamilyValues, FontString, NonDeletedDucElement } from "../../types/elements";
3
+ import { GeometricPoint } from "../../types/geometryTypes";
4
+ import { ExtractSetType } from "../../types/utility-types";
5
+ import { getBoundTextElementPosition } from "./linearElement";
6
+ import { SupportedMeasures } from "../../technical/scopes";
7
7
  export declare const computeBoundTextPosition: (container: DucElement, boundTextElement: DucTextElementWithContainer, elementsMap: ElementsMap, currentScope: SupportedMeasures) => {
8
8
  x: ScopedValue;
9
9
  y: ScopedValue;
@@ -34,7 +34,7 @@ export declare const getContainerCoords: (container: NonDeletedDucElement) => {
34
34
  x: RawValue;
35
35
  y: RawValue;
36
36
  };
37
- export declare const getTextElementAngle: (textElement: DucTextElement, container: DucTextContainer | null) => import("ducjs/types").Radian;
37
+ export declare const getTextElementAngle: (textElement: DucTextElement, container: DucTextContainer | null) => import("../..").Radian;
38
38
  export declare const shouldAllowVerticalAlign: (selectedElements: NonDeletedDucElement[], elementsMap: ElementsMap) => boolean;
39
39
  export declare const suppportsHorizontalAlign: (selectedElements: NonDeletedDucElement[], elementsMap: ElementsMap) => boolean;
40
40
  declare const VALID_CONTAINER_TYPES: Set<string>;
@@ -1,11 +1,11 @@
1
- import { TEXT_ALIGN, VERTICAL_ALIGN } from "ducjs/flatbuffers/duc";
2
- import { isArrowElement, isBoundToContainer, isTextElement } from "ducjs/types/elements/typeChecks";
3
- import { getContainerElement, getElementAbsoluteCoords, getResizedElementAbsoluteCoords } from "ducjs/utils/bounds";
4
- import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, FONT_FAMILY, WINDOWS_EMOJI_FALLBACK_FONT } from "ducjs/utils/constants";
5
- import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "ducjs/utils/elements/linearElement";
6
- import { adjustXYWithRotation } from "ducjs/utils/math";
7
- import { normalizeText } from "ducjs/utils/normalize";
8
- import { getPrecisionValueFromRaw, getScopedBezierPointFromDucPoint } from "ducjs/technical/scopes";
1
+ import { TEXT_ALIGN, VERTICAL_ALIGN } from "../../flatbuffers/duc";
2
+ import { isArrowElement, isBoundToContainer, isTextElement } from "../../types/elements/typeChecks";
3
+ import { getContainerElement, getElementAbsoluteCoords, getResizedElementAbsoluteCoords } from "../bounds";
4
+ import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, FONT_FAMILY, WINDOWS_EMOJI_FALLBACK_FONT } from "../constants";
5
+ import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "./linearElement";
6
+ import { adjustXYWithRotation } from "../math";
7
+ import { normalizeText } from "../normalize";
8
+ import { getPrecisionValueFromRaw, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
9
9
  export const computeBoundTextPosition = (container, boundTextElement, elementsMap, currentScope) => {
10
10
  if (isArrowElement(container)) {
11
11
  const coords = getBoundTextElementPosition(container, boundTextElement, elementsMap, currentScope);
@@ -470,8 +470,10 @@ export const getTextFromElements = (elements, separator = "\n\n") => {
470
470
  return text;
471
471
  };
472
472
  export const getFontFamilyString = ({ fontFamily, }) => {
473
+ // Handle both number and string fontFamily values
474
+ const fontFamilyNum = typeof fontFamily === 'string' ? parseInt(fontFamily, 10) : fontFamily;
473
475
  for (const [fontFamilyString, id] of Object.entries(FONT_FAMILY)) {
474
- if (id === fontFamily) {
476
+ if (id === fontFamilyNum) {
475
477
  return `${fontFamilyString}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
476
478
  }
477
479
  }
@@ -1,4 +1,4 @@
1
- import { AnnotationScale, ViewportScale } from "ducjs/types";
1
+ import { AnnotationScale, ViewportScale } from "../../types";
2
2
  /**
3
3
  * Utility functions to convert between the two scales
4
4
  */
@@ -48,8 +48,8 @@ export function reviveEncodedFunction(val) {
48
48
  return val;
49
49
  try {
50
50
  // Wrap in parentheses to handle arrow functions and function declarations uniformly
51
- // eslint-disable-next-line no-eval
52
- const revived = eval(`(${code})`);
51
+ // eslint-disable-next-line no-new-func
52
+ const revived = new Function(`return (${code})`)();
53
53
  if (typeof revived === "function")
54
54
  return revived;
55
55
  return val;
@@ -9,6 +9,7 @@ export * from "./url";
9
9
  export * from "./version";
10
10
  export * from "./filebyte";
11
11
  export * from "./functionCodec";
12
+ export * from "./traverse";
12
13
  /**
13
14
  * supply `null` as message if non-never value is valid, you just need to
14
15
  * typecheck against it
@@ -9,6 +9,7 @@ export * from "./url";
9
9
  export * from "./version";
10
10
  export * from "./filebyte";
11
11
  export * from "./functionCodec";
12
+ export * from "./traverse";
12
13
  /**
13
14
  * supply `null` as message if non-never value is valid, you just need to
14
15
  * typecheck against it
@@ -1,4 +1,4 @@
1
- import type { GALine, GADirection, GAPoint } from "ducjs/utils/math/algebra/ga";
1
+ import type { GALine, GADirection, GAPoint } from "./ga";
2
2
  /**
3
3
  * A direction is stored as an array `[0, 0, 0, 0, y, x, 0, 0]` representing
4
4
  * vector `(x, y)`.
@@ -1,4 +1,4 @@
1
- import * as GA from "ducjs/utils/math/algebra/ga";
1
+ import * as GA from "./ga";
2
2
  /**
3
3
  * A direction is stored as an array `[0, 0, 0, 0, y, x, 0, 0]` representing
4
4
  * vector `(x, y)`.
@@ -1,4 +1,4 @@
1
- import type { GALine, GAPoint } from "ducjs/utils/math/algebra/ga";
1
+ import type { GALine, GAPoint } from "./ga";
2
2
  /**
3
3
  * A line is stored as an array `[0, c, a, b, 0, 0, 0, 0]` representing:
4
4
  * c * e0 + a * e1 + b*e2
@@ -1,4 +1,4 @@
1
- import * as GA from "ducjs/utils/math/algebra/ga";
1
+ import * as GA from "./ga";
2
2
  /**
3
3
  * A line is stored as an array `[0, c, a, b, 0, 0, 0, 0]` representing:
4
4
  * c * e0 + a * e1 + b*e2
@@ -1,4 +1,4 @@
1
- import type { GAPoint, GALine } from "ducjs/utils/math/algebra/ga";
1
+ import type { GAPoint, GALine } from "./ga";
2
2
  export declare const fromPoint: ([x, y]: readonly [number, number]) => GAPoint;
3
3
  export declare const toTuple: (point: GAPoint) => [number, number];
4
4
  export declare const abs: (point: GAPoint) => GAPoint;
@@ -1,6 +1,6 @@
1
- import * as GA from "ducjs/utils/math/algebra/ga";
2
- import * as GALines from "ducjs/utils/math/algebra/galines";
3
- import { join } from "ducjs/utils/math/algebra/ga";
1
+ import * as GA from "./ga";
2
+ import * as GALines from "./galines";
3
+ import { join } from "./ga";
4
4
  export const fromPoint = ([x, y]) => [
5
5
  0,
6
6
  0,
@@ -1,4 +1,4 @@
1
- import type { GALine, GADirection, GAPoint, GATransform } from "ducjs/utils/math/algebra/ga";
1
+ import type { GALine, GADirection, GAPoint, GATransform } from "./ga";
2
2
  /**
3
3
  * TODO: docs
4
4
  */
@@ -1,5 +1,5 @@
1
- import * as GA from "ducjs/utils/math/algebra/ga";
2
- import * as GADirections from "ducjs/utils/math/algebra/gadirections";
1
+ import * as GA from "./ga";
2
+ import * as GADirections from "./gadirections";
3
3
  /**
4
4
  * TODO: docs
5
5
  */
@@ -1,5 +1,5 @@
1
- import { Bounds, LineSegment } from "ducjs/types/geometryTypes";
2
- import { GeometricPoint } from "ducjs/types/geometryTypes";
1
+ import { Bounds, LineSegment } from "../../types/geometryTypes";
2
+ import { GeometricPoint } from "../../types/geometryTypes";
3
3
  export declare function getBBox(line: LineSegment): Bounds;
4
4
  export declare function crossProduct(a: GeometricPoint, b: GeometricPoint): number;
5
5
  export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;