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,11 +1,11 @@
1
- import { BLENDING } from "ducjs/flatbuffers/duc";
2
- import { Standard } from "ducjs/technical/standards";
3
- import type { Dictionary, DucExternalFiles, DucGlobalState, ImportedDataState, LibraryItems, PrecisionValue, Scope, VersionGraph } from "ducjs/types";
4
- import { DucLocalState } from "ducjs/types";
5
- import type { _DucStackBase, BezierMirroring, DucBlock, DucElement, DucGroup, DucHead, DucLayer, DucRegion, ElementBackground, ElementContentBase, ElementStroke, ExternalFileId, FillStyle, ImageStatus, LineHead, OrderedDucElement, StrokeCap, StrokeJoin, StrokePreference, StrokeSidePreference, StrokeStyle, TextAlign, VerticalAlign } from "ducjs/types/elements";
6
- import { Percentage, Radian } from "ducjs/types/geometryTypes";
7
- import { ValueOf } from "ducjs/types/utility-types";
8
- import { VERSIONS } from "ducjs/utils/constants";
1
+ import { BLENDING } from "../flatbuffers/duc";
2
+ import { Standard } from "../technical/standards";
3
+ import type { Dictionary, DucExternalFiles, DucGlobalState, ImportedDataState, LibraryItems, PrecisionValue, Scope, VersionGraph } from "../types";
4
+ import { DucLocalState } from "../types";
5
+ import type { _DucStackBase, BezierMirroring, DucBlock, DucElement, DucGroup, DucHead, DucLayer, DucRegion, ElementBackground, ElementContentBase, ElementStroke, ExternalFileId, FillStyle, ImageStatus, LineHead, OrderedDucElement, StrokeCap, StrokeJoin, StrokePreference, StrokeSidePreference, StrokeStyle, TextAlign, VerticalAlign } from "../types/elements";
6
+ import { Percentage, Radian } from "../types/geometryTypes";
7
+ import { ValueOf } from "../types/utility-types";
8
+ import { VERSIONS } from "../utils/constants";
9
9
  export type RestoredLocalState = Omit<DucLocalState, "offsetTop" | "offsetLeft" | "width" | "height">;
10
10
  export type RestoredDataState = {
11
11
  thumbnail: Uint8Array | undefined;
@@ -20,6 +20,7 @@ export type RestoredDataState = {
20
20
  layers: DucLayer[];
21
21
  standards: Standard[];
22
22
  versionGraph: VersionGraph | undefined;
23
+ id: string;
23
24
  };
24
25
  export interface ExportedLibraryData {
25
26
  type: string;
@@ -41,7 +42,10 @@ export type ElementsConfig = {
41
42
  */
42
43
  passThroughElementIds?: string[];
43
44
  };
44
- export declare const restore: (data: ImportedDataState | null, elementsConfig: ElementsConfig) => RestoredDataState;
45
+ export type RestoreConfig = {
46
+ forceScope?: Scope;
47
+ };
48
+ export declare const restore: (data: ImportedDataState | null, elementsConfig: ElementsConfig, restoreConfig?: RestoreConfig) => RestoredDataState;
45
49
  export declare const restoreFiles: (importedFiles: unknown) => DucExternalFiles;
46
50
  export declare const restoreDictionary: (importedDictionary: unknown) => Dictionary;
47
51
  /**
@@ -100,7 +104,7 @@ export declare const restoreGlobalState: (importedState?: Partial<DucGlobalState
100
104
  * @param restoredGlobalState - The complete and valid global state for the document.
101
105
  * @returns A complete and valid DucLocalState object.
102
106
  */
103
- export declare const restoreLocalState: (importedState: Partial<DucLocalState> | undefined, restoredGlobalState: RestoredDataState["globalState"], restoredStandards: RestoredDataState["standards"]) => DucLocalState;
107
+ export declare const restoreLocalState: (importedState: Partial<DucLocalState> | undefined, restoredGlobalState: RestoredDataState["globalState"], restoredStandards: RestoredDataState["standards"], forceScope?: Scope) => DucLocalState;
104
108
  export declare const restoreVersionGraph: (importedGraph: any) => RestoredDataState["versionGraph"];
105
109
  /**
106
110
  * Restores common properties for elements leveraging _DucStackBase.
@@ -1,18 +1,19 @@
1
- import { BEZIER_MIRRORING, BLENDING, BOOLEAN_OPERATION, ELEMENT_CONTENT_PREFERENCE, IMAGE_STATUS, LINE_HEAD, PRUNING_LEVEL, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN, } from "ducjs/flatbuffers/duc";
2
- import { restoreElements } from "ducjs/restore/restoreElements";
3
- import { isStandardIdPresent, restoreStandards, } from "ducjs/restore/restoreStandards";
4
- import { getPrecisionScope } from "ducjs/technical/measurements";
5
- import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, NEUTRAL_SCOPE, ScaleFactors } from "ducjs/technical/scopes";
6
- import { PREDEFINED_STANDARDS } from "ducjs/technical/standards";
7
- import { base64ToUint8Array, getDefaultGlobalState, getDefaultLocalState, getZoom, isEncodedFunctionString, isFiniteNumber, reviveEncodedFunction, } from "ducjs/utils";
8
- import { DEFAULT_ELEMENT_PROPS, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, DEFAULT_ZOOM_STEP, MAX_ZOOM_STEP, MIN_ZOOM_STEP, } from "ducjs/utils/constants";
9
- import { getDefaultStackProperties } from "ducjs/utils/elements";
1
+ import { BEZIER_MIRRORING, BLENDING, BOOLEAN_OPERATION, ELEMENT_CONTENT_PREFERENCE, IMAGE_STATUS, LINE_HEAD, PRUNING_LEVEL, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN, } from "../flatbuffers/duc";
2
+ import { nanoid } from "nanoid";
3
+ import { restoreElements } from "./restoreElements";
4
+ import { isStandardIdPresent, restoreStandards, } from "./restoreStandards";
5
+ import { getPrecisionScope } from "../technical/measurements";
6
+ import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, NEUTRAL_SCOPE, ScaleFactors } from "../technical/scopes";
7
+ import { PREDEFINED_STANDARDS } from "../technical/standards";
8
+ import { base64ToUint8Array, getDefaultGlobalState, getDefaultLocalState, getZoom, isEncodedFunctionString, isFiniteNumber, reviveEncodedFunction, } from "../utils";
9
+ import { DEFAULT_ELEMENT_PROPS, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, DEFAULT_ZOOM_STEP, MAX_ZOOM_STEP, MIN_ZOOM_STEP, } from "../utils/constants";
10
+ import { getDefaultStackProperties } from "../utils/elements";
10
11
  import tinycolor from "tinycolor2";
11
- export const restore = (data, elementsConfig) => {
12
+ export const restore = (data, elementsConfig, restoreConfig = {}) => {
12
13
  const restoredStandards = restoreStandards(data === null || data === void 0 ? void 0 : data.standards);
13
14
  const restoredDictionary = restoreDictionary(data === null || data === void 0 ? void 0 : data.dictionary);
14
15
  const restoredGlobalState = restoreGlobalState(data === null || data === void 0 ? void 0 : data.globalState);
15
- const restoredLocalState = restoreLocalState(data === null || data === void 0 ? void 0 : data.localState, restoredGlobalState, restoredStandards);
16
+ const restoredLocalState = restoreLocalState(data === null || data === void 0 ? void 0 : data.localState, restoredGlobalState, restoredStandards, restoreConfig.forceScope);
16
17
  const restoredElementsConfig = Object.assign(Object.assign({}, elementsConfig), { localState: restoredLocalState });
17
18
  const restoredBlocks = restoreBlocks(data === null || data === void 0 ? void 0 : data.blocks, restoredLocalState.scope, restoredElementsConfig);
18
19
  const restoredRegions = restoreRegions(data === null || data === void 0 ? void 0 : data.regions);
@@ -20,6 +21,9 @@ export const restore = (data, elementsConfig) => {
20
21
  const restoredLayers = restoreLayers(data === null || data === void 0 ? void 0 : data.layers, restoredLocalState.scope);
21
22
  const restoredElements = restoreElements(data === null || data === void 0 ? void 0 : data.elements, restoredLocalState.scope, restoredBlocks, restoredElementsConfig);
22
23
  const restoredVersionGraph = restoreVersionGraph(data === null || data === void 0 ? void 0 : data.versionGraph);
24
+ // Generate a new ID if none exists or if it's empty
25
+ const parsedId = data === null || data === void 0 ? void 0 : data.id;
26
+ const restoredId = (parsedId && parsedId.trim().length > 0) ? parsedId : nanoid();
23
27
  return {
24
28
  dictionary: restoredDictionary,
25
29
  thumbnail: isValidUint8Array(data === null || data === void 0 ? void 0 : data.thumbnail),
@@ -33,6 +37,7 @@ export const restore = (data, elementsConfig) => {
33
37
  localState: restoredLocalState,
34
38
  globalState: restoredGlobalState,
35
39
  files: restoreFiles(data === null || data === void 0 ? void 0 : data.files),
40
+ id: restoredId,
36
41
  };
37
42
  };
38
43
  export const restoreFiles = (importedFiles) => {
@@ -211,13 +216,13 @@ export const restoreBlocks = (blocks, currentScope, elementsConfig) => {
211
216
  * @returns A complete and valid DucGlobalState object.
212
217
  */
213
218
  export const restoreGlobalState = (importedState = {}) => {
214
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
219
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
215
220
  const defaults = getDefaultGlobalState();
216
- const linearPrecision = isValidFinitePositiveByteValue(importedState.coordDecimalPlaces, defaults.displayPrecision.linear);
217
- return Object.assign(Object.assign({}, defaults), { name: (_a = importedState.name) !== null && _a !== void 0 ? _a : defaults.name, viewBackgroundColor: (_b = importedState.viewBackgroundColor) !== null && _b !== void 0 ? _b : defaults.viewBackgroundColor, mainScope: (_c = isValidAppStateScopeValue(importedState.mainScope)) !== null && _c !== void 0 ? _c : defaults.mainScope, scopeExponentThreshold: isValidAppStateScopeExponentThresholdValue(importedState.scopeExponentThreshold, defaults.scopeExponentThreshold), dashSpacingScale: (_d = importedState.dashSpacingScale) !== null && _d !== void 0 ? _d : defaults.dashSpacingScale, isDashSpacingAffectedByViewportScale: (_e = importedState.isDashSpacingAffectedByViewportScale) !== null && _e !== void 0 ? _e : defaults.isDashSpacingAffectedByViewportScale, dimensionsAssociativeByDefault: (_f = importedState.dimensionsAssociativeByDefault) !== null && _f !== void 0 ? _f : defaults.dimensionsAssociativeByDefault, useAnnotativeScaling: (_g = importedState.useAnnotativeScaling) !== null && _g !== void 0 ? _g : defaults.useAnnotativeScaling, displayPrecision: {
221
+ const linearPrecision = isValidFinitePositiveByteValue((_a = importedState === null || importedState === void 0 ? void 0 : importedState.displayPrecision) === null || _a === void 0 ? void 0 : _a.linear, defaults.displayPrecision.linear);
222
+ return Object.assign(Object.assign({}, defaults), { name: (_b = importedState === null || importedState === void 0 ? void 0 : importedState.name) !== null && _b !== void 0 ? _b : defaults.name, viewBackgroundColor: (_c = importedState === null || importedState === void 0 ? void 0 : importedState.viewBackgroundColor) !== null && _c !== void 0 ? _c : defaults.viewBackgroundColor, mainScope: (_d = isValidAppStateScopeValue(importedState === null || importedState === void 0 ? void 0 : importedState.mainScope)) !== null && _d !== void 0 ? _d : defaults.mainScope, scopeExponentThreshold: isValidAppStateScopeExponentThresholdValue(importedState === null || importedState === void 0 ? void 0 : importedState.scopeExponentThreshold, defaults.scopeExponentThreshold), dashSpacingScale: (_e = importedState === null || importedState === void 0 ? void 0 : importedState.dashSpacingScale) !== null && _e !== void 0 ? _e : defaults.dashSpacingScale, isDashSpacingAffectedByViewportScale: (_f = importedState === null || importedState === void 0 ? void 0 : importedState.isDashSpacingAffectedByViewportScale) !== null && _f !== void 0 ? _f : defaults.isDashSpacingAffectedByViewportScale, dimensionsAssociativeByDefault: (_g = importedState === null || importedState === void 0 ? void 0 : importedState.dimensionsAssociativeByDefault) !== null && _g !== void 0 ? _g : defaults.dimensionsAssociativeByDefault, useAnnotativeScaling: (_h = importedState === null || importedState === void 0 ? void 0 : importedState.useAnnotativeScaling) !== null && _h !== void 0 ? _h : defaults.useAnnotativeScaling, displayPrecision: {
218
223
  linear: linearPrecision,
219
- angular: (_j = (_h = importedState.displayPrecision) === null || _h === void 0 ? void 0 : _h.angular) !== null && _j !== void 0 ? _j : defaults.displayPrecision.angular,
220
- }, pruningLevel: importedState.pruningLevel &&
224
+ angular: (_k = (_j = importedState === null || importedState === void 0 ? void 0 : importedState.displayPrecision) === null || _j === void 0 ? void 0 : _j.angular) !== null && _k !== void 0 ? _k : defaults.displayPrecision.angular,
225
+ }, pruningLevel: (importedState === null || importedState === void 0 ? void 0 : importedState.pruningLevel) &&
221
226
  Object.values(PRUNING_LEVEL).includes(importedState.pruningLevel)
222
227
  ? importedState.pruningLevel
223
228
  : PRUNING_LEVEL.BALANCED });
@@ -231,16 +236,18 @@ export const restoreGlobalState = (importedState = {}) => {
231
236
  * @param restoredGlobalState - The complete and valid global state for the document.
232
237
  * @returns A complete and valid DucLocalState object.
233
238
  */
234
- export const restoreLocalState = (importedState = {}, restoredGlobalState, restoredStandards) => {
239
+ export const restoreLocalState = (importedState = {}, restoredGlobalState, restoredStandards, forceScope) => {
235
240
  var _a, _b, _c, _d, _e, _f, _g, _h;
236
241
  const defaults = getDefaultLocalState();
237
- const zoom = getZoom((_b = (_a = importedState.zoom) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : defaults.zoom.value, restoredGlobalState.mainScope, restoredGlobalState.scopeExponentThreshold);
238
- const scope = isValidPrecisionScopeValue(zoom.value, restoredGlobalState.mainScope, restoredGlobalState.scopeExponentThreshold);
239
- return Object.assign(Object.assign(Object.assign({}, defaults), importedState), { scope, activeStandardId: isValidStandardId(importedState.activeStandardId, restoredStandards, defaults.activeStandardId), isBindingEnabled: isValidBoolean(importedState.isBindingEnabled, defaults.isBindingEnabled), penMode: isValidBoolean(importedState.penMode, defaults.penMode), scrollX: importedState.scrollX
242
+ const zoom = getZoom((_b = (_a = importedState === null || importedState === void 0 ? void 0 : importedState.zoom) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : defaults.zoom.value, restoredGlobalState.mainScope, restoredGlobalState.scopeExponentThreshold);
243
+ const scope = forceScope
244
+ ? isValidScopeValue(forceScope)
245
+ : isValidPrecisionScopeValue(zoom.value, restoredGlobalState.mainScope, restoredGlobalState.scopeExponentThreshold);
246
+ return Object.assign(Object.assign(Object.assign({}, defaults), importedState), { scope, activeStandardId: isValidStandardId(importedState === null || importedState === void 0 ? void 0 : importedState.activeStandardId, restoredStandards, defaults.activeStandardId), isBindingEnabled: isValidBoolean(importedState === null || importedState === void 0 ? void 0 : importedState.isBindingEnabled, defaults.isBindingEnabled), penMode: isValidBoolean(importedState === null || importedState === void 0 ? void 0 : importedState.penMode, defaults.penMode), scrollX: (importedState === null || importedState === void 0 ? void 0 : importedState.scrollX)
240
247
  ? restorePrecisionValue(importedState.scrollX, NEUTRAL_SCOPE, scope)
241
- : getPrecisionValueFromRaw(defaults.scrollX.value, NEUTRAL_SCOPE, scope), scrollY: importedState.scrollY
248
+ : getPrecisionValueFromRaw(defaults.scrollX.value, NEUTRAL_SCOPE, scope), scrollY: (importedState === null || importedState === void 0 ? void 0 : importedState.scrollY)
242
249
  ? restorePrecisionValue(importedState.scrollY, NEUTRAL_SCOPE, scope)
243
- : getPrecisionValueFromRaw(defaults.scrollY.value, NEUTRAL_SCOPE, scope), zoom, activeGridSettings: (_c = importedState.activeGridSettings) !== null && _c !== void 0 ? _c : defaults.activeGridSettings, activeSnapSettings: (_d = importedState.activeSnapSettings) !== null && _d !== void 0 ? _d : defaults.activeSnapSettings, currentItemStroke: (_e = validateStroke(importedState.currentItemStroke, scope, scope)) !== null && _e !== void 0 ? _e : defaults.currentItemStroke, currentItemBackground: (_f = validateBackground(importedState.currentItemBackground)) !== null && _f !== void 0 ? _f : defaults.currentItemBackground, currentItemOpacity: isValidPercentageValue(importedState.currentItemOpacity, defaults.currentItemOpacity), currentItemStartLineHead: (_g = isValidLineHeadValue(importedState.currentItemStartLineHead)) !== null && _g !== void 0 ? _g : defaults.currentItemStartLineHead, currentItemEndLineHead: (_h = isValidLineHeadValue(importedState.currentItemEndLineHead)) !== null && _h !== void 0 ? _h : defaults.currentItemEndLineHead });
250
+ : getPrecisionValueFromRaw(defaults.scrollY.value, NEUTRAL_SCOPE, scope), zoom, activeGridSettings: (_c = importedState === null || importedState === void 0 ? void 0 : importedState.activeGridSettings) !== null && _c !== void 0 ? _c : defaults.activeGridSettings, activeSnapSettings: (_d = importedState === null || importedState === void 0 ? void 0 : importedState.activeSnapSettings) !== null && _d !== void 0 ? _d : defaults.activeSnapSettings, currentItemStroke: (_e = validateStroke(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemStroke, scope, scope)) !== null && _e !== void 0 ? _e : defaults.currentItemStroke, currentItemBackground: (_f = validateBackground(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemBackground)) !== null && _f !== void 0 ? _f : defaults.currentItemBackground, currentItemOpacity: isValidPercentageValue(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemOpacity, defaults.currentItemOpacity), currentItemStartLineHead: (_g = isValidLineHeadValue(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemStartLineHead)) !== null && _g !== void 0 ? _g : defaults.currentItemStartLineHead, currentItemEndLineHead: (_h = isValidLineHeadValue(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemEndLineHead)) !== null && _h !== void 0 ? _h : defaults.currentItemEndLineHead });
244
251
  };
245
252
  export const restoreVersionGraph = (importedGraph) => {
246
253
  if (!importedGraph || typeof importedGraph !== "object") {
@@ -1,5 +1,5 @@
1
- import { ElementsConfig, RestoredDataState } from "ducjs/restore/restoreDataState";
2
- import { BezierMirroring, DucElement, DucFreeDrawEasing, DucLocalState, DucPoint, ImportedDataState, OrderedDucElement, PrecisionValue, Scope } from "ducjs/types";
1
+ import { ElementsConfig, RestoredDataState } from "./restoreDataState";
2
+ import { BezierMirroring, DucElement, DucFreeDrawEasing, DucLocalState, DucPoint, ImportedDataState, OrderedDucElement, PrecisionValue, Scope } from "../types";
3
3
  /**
4
4
  * Restores a point that might have legacy format (x,y as numbers)
5
5
  * @param point - The point to restore
@@ -1,9 +1,9 @@
1
1
  import { isValidBezierMirroringValue, isValidBlendingValue, isValidBoolean, isValidBoolean as isValidBooleanValue, // Renaming to avoid conflict
2
- isValidColor, isValidDucHead, isValidEnumValue, isValidFunction, isValidImageScaleValue, isValidImageStatusValue, isValidPercentageValue, isValidPolygonSides, isValidRadianValue, isValidString, isValidTextAlignValue, isValidVerticalAlignValue, restoreDucStackProperties, restorePrecisionValue, validateBackground, validateStroke } from "ducjs/restore/restoreDataState";
3
- import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScaledZoomValueForScope, getScopedBezierPointFromDucPoint, getScopedZoomValue, NEUTRAL_SCOPE, ScaleFactors, } from "ducjs/technical/scopes";
4
- import { isElbowArrow, isLinearElement, isTextElement, } from "ducjs/types";
5
- import { arrayToMap, bumpVersion, DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, detectLineHeight, FONT_FAMILY, getContainerElement, getDefaultLocalState, getDefaultTableData, getNormalizedDimensions, getNormalizedPoints, getNormalizedZoom, getSizeFromPoints, getUpdatedTimestamp, isFiniteNumber, isInvisiblySmallElement, LINE_CONFIRM_THRESHOLD, mergeOverlappingPoints, migratePoints, normalizeFixedPoint, normalizeLink, randomId, refreshTextDimensions, validateClosedPath, } from "ducjs/utils";
6
- import { AXIS, BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, GDT_SYMBOL, LEADER_CONTENT_TYPE, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT, } from "ducjs/flatbuffers/duc";
2
+ isValidColor, isValidDucHead, isValidEnumValue, isValidFunction, isValidImageScaleValue, isValidImageStatusValue, isValidPercentageValue, isValidPolygonSides, isValidRadianValue, isValidString, isValidTextAlignValue, isValidVerticalAlignValue, restoreDucStackProperties, restorePrecisionValue, validateBackground, validateStroke } from "./restoreDataState";
3
+ import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScaledZoomValueForScope, getScopedBezierPointFromDucPoint, getScopedZoomValue, NEUTRAL_SCOPE, ScaleFactors, } from "../technical/scopes";
4
+ import { isElbowArrow, isLinearElement, isTextElement, } from "../types";
5
+ import { arrayToMap, bumpVersion, DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, detectLineHeight, FONT_FAMILY, getContainerElement, getDefaultLocalState, getDefaultTableData, getNormalizedDimensions, getNormalizedPoints, getNormalizedZoom, getSizeFromPoints, getUpdatedTimestamp, isFiniteNumber, isInvisiblySmallElement, LINE_CONFIRM_THRESHOLD, mergeOverlappingPoints, migratePoints, normalizeFixedPoint, normalizeLink, randomId, refreshTextDimensions, validateClosedPath, } from "../utils";
6
+ import { AXIS, BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, GDT_SYMBOL, LEADER_CONTENT_TYPE, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT, } from "../flatbuffers/duc";
7
7
  import tinycolor from "tinycolor2";
8
8
  const restoreElementWithProperties = (element, extra, localState, globalState) => {
9
9
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -1258,17 +1258,24 @@ const restoreFcfDatumDefinition = (def, elementScope, currentScope, restoredBloc
1258
1258
  const restoreTextStyle = (style, currentScope) => {
1259
1259
  var _a, _b, _c;
1260
1260
  const defaultLineHeight = 1.15;
1261
- return Object.assign(Object.assign(Object.assign({}, ((style === null || style === void 0 ? void 0 : style.background)
1262
- ? { background: style.background.map(validateBackground) }
1263
- : { background: [DEFAULT_ELEMENT_PROPS.background] })), ((style === null || style === void 0 ? void 0 : style.stroke)
1264
- ? {
1265
- stroke: style.stroke.map((s) => validateStroke(s, NEUTRAL_SCOPE, currentScope)),
1266
- }
1267
- : { stroke: [DEFAULT_ELEMENT_PROPS.stroke] })), { roundness: restorePrecisionValue(style === null || style === void 0 ? void 0 : style.roundness, NEUTRAL_SCOPE, currentScope, DEFAULT_ELEMENT_PROPS.roundness.value), opacity: isValidPercentageValue(style === null || style === void 0 ? void 0 : style.opacity, DEFAULT_ELEMENT_PROPS.opacity), blending: isValidBlendingValue(style === null || style === void 0 ? void 0 : style.blending),
1261
+ return {
1268
1262
  // Text-specific styles
1269
- isLtr: isValidBoolean(style === null || style === void 0 ? void 0 : style.isLtr, true), fontFamily: getFontFamilyByName(style === null || style === void 0 ? void 0 : style.fontFamily), bigFontFamily: isValidString(style === null || style === void 0 ? void 0 : style.bigFontFamily, "sans-serif"), textAlign: isValidTextAlignValue(style === null || style === void 0 ? void 0 : style.textAlign), verticalAlign: isValidVerticalAlignValue(style === null || style === void 0 ? void 0 : style.verticalAlign), lineHeight: (_a = style === null || style === void 0 ? void 0 : style.lineHeight) !== null && _a !== void 0 ? _a : defaultLineHeight, lineSpacing: restoreLineSpacing(style === null || style === void 0 ? void 0 : style.lineSpacing, (_b = style === null || style === void 0 ? void 0 : style.lineHeight) !== null && _b !== void 0 ? _b : defaultLineHeight.valueOf(), currentScope), obliqueAngle: isValidRadianValue(style === null || style === void 0 ? void 0 : style.obliqueAngle, 0), fontSize: restorePrecisionValue(style === null || style === void 0 ? void 0 : style.fontSize, NEUTRAL_SCOPE, currentScope, DEFAULT_FONT_SIZE), paperTextHeight: (style === null || style === void 0 ? void 0 : style.paperTextHeight)
1263
+ isLtr: isValidBoolean(style === null || style === void 0 ? void 0 : style.isLtr, true),
1264
+ fontFamily: getFontFamilyByName(style === null || style === void 0 ? void 0 : style.fontFamily),
1265
+ bigFontFamily: isValidString(style === null || style === void 0 ? void 0 : style.bigFontFamily, "sans-serif"),
1266
+ textAlign: isValidTextAlignValue(style === null || style === void 0 ? void 0 : style.textAlign),
1267
+ verticalAlign: isValidVerticalAlignValue(style === null || style === void 0 ? void 0 : style.verticalAlign),
1268
+ lineHeight: (_a = style === null || style === void 0 ? void 0 : style.lineHeight) !== null && _a !== void 0 ? _a : defaultLineHeight,
1269
+ lineSpacing: restoreLineSpacing(style === null || style === void 0 ? void 0 : style.lineSpacing, (_b = style === null || style === void 0 ? void 0 : style.lineHeight) !== null && _b !== void 0 ? _b : defaultLineHeight.valueOf(), currentScope),
1270
+ obliqueAngle: isValidRadianValue(style === null || style === void 0 ? void 0 : style.obliqueAngle, 0),
1271
+ fontSize: restorePrecisionValue(style === null || style === void 0 ? void 0 : style.fontSize, NEUTRAL_SCOPE, currentScope, DEFAULT_FONT_SIZE),
1272
+ paperTextHeight: (style === null || style === void 0 ? void 0 : style.paperTextHeight)
1270
1273
  ? restorePrecisionValue(style.paperTextHeight, NEUTRAL_SCOPE, currentScope)
1271
- : undefined, widthFactor: (_c = style === null || style === void 0 ? void 0 : style.widthFactor) !== null && _c !== void 0 ? _c : 1, isUpsideDown: isValidBoolean(style === null || style === void 0 ? void 0 : style.isUpsideDown, false), isBackwards: isValidBoolean(style === null || style === void 0 ? void 0 : style.isBackwards, false) });
1274
+ : undefined,
1275
+ widthFactor: (_c = style === null || style === void 0 ? void 0 : style.widthFactor) !== null && _c !== void 0 ? _c : 1,
1276
+ isUpsideDown: isValidBoolean(style === null || style === void 0 ? void 0 : style.isUpsideDown, false),
1277
+ isBackwards: isValidBoolean(style === null || style === void 0 ? void 0 : style.isBackwards, false),
1278
+ };
1272
1279
  };
1273
1280
  const restoreHeadsOverride = (heads, restoredBlocks, elementScope, currentScope) => {
1274
1281
  if (!Array.isArray(heads) || heads.length !== 2)
@@ -1,5 +1,5 @@
1
- import { Standard } from "ducjs/technical/standards";
2
- import { Scope } from "ducjs/types";
1
+ import { Standard } from "../technical/standards";
2
+ import { Scope } from "../types";
3
3
  export declare const restoreStandards: (standards: any, currentScope?: Scope) => Standard[];
4
4
  /**
5
5
  * Checks if a given id is present in the standards array.
@@ -1,7 +1,7 @@
1
- import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT, GRID_DISPLAY_TYPE, GRID_TYPE, UNIT_SYSTEM, } from "ducjs/flatbuffers/duc";
2
- import { isValidBoolean, isValidEnumValue, isValidRadianValue, isValidString, restorePrecisionValue } from "ducjs/restore/restoreDataState";
3
- import { NEUTRAL_SCOPE, ScaleFactors } from "ducjs/technical";
4
- import { PREDEFINED_STANDARDS } from "ducjs/technical/standards";
1
+ import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT, GRID_DISPLAY_TYPE, GRID_TYPE, UNIT_SYSTEM, } from "../flatbuffers/duc";
2
+ import { isValidBoolean, isValidEnumValue, isValidRadianValue, isValidString, restorePrecisionValue } from "./restoreDataState";
3
+ import { NEUTRAL_SCOPE, ScaleFactors } from "../technical";
4
+ import { PREDEFINED_STANDARDS } from "../technical/standards";
5
5
  export const restoreStandards = (standards,
6
6
  // Pass current scope to resolve precision values if needed
7
7
  currentScope = NEUTRAL_SCOPE) => {
@@ -1,3 +1,4 @@
1
- import { ImportedDataState } from "ducjs/types";
1
+ import { ImportedDataState } from "./types";
2
+ import { RestoreConfig } from "./restore";
2
3
  export declare const DUC_SCHEMA_VERSION: any;
3
- export declare const serializeDuc: (data: ImportedDataState, useScopedValues?: boolean, passThroughElementIds?: string[]) => Promise<Uint8Array>;
4
+ export declare const serializeDuc: (data: ImportedDataState, useScopedValues?: boolean, passThroughElementIds?: string[], restoreConfig?: RestoreConfig) => Promise<Uint8Array>;
package/dist/serialize.js CHANGED
@@ -16,10 +16,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
16
16
  cast to number at the final write site (e.g. pv.value).
17
17
  - Keep args strongly typed. Never use any for function args.
18
18
  */
19
- import * as Duc from "ducjs/flatbuffers/duc";
20
19
  import * as flatbuffers from "flatbuffers";
21
- import { restore } from "ducjs/restore";
22
- import { encodeFunctionString, EXPORT_DATA_TYPES } from "ducjs/utils";
20
+ import * as Duc from "./flatbuffers/duc";
21
+ import { restore } from "./restore";
22
+ import { encodeFunctionString, EXPORT_DATA_TYPES } from "./utils";
23
23
  /**
24
24
  * Basic helpers
25
25
  */
@@ -584,13 +584,10 @@ function writeLineSpacing(b, ls, usv) {
584
584
  return Duc.LineSpacing.endLineSpacing(b);
585
585
  }
586
586
  function writeTextStyle(b, s, usv) {
587
- const base = writeStylesBase(b, s, usv);
588
587
  const lineSpacing = writeLineSpacing(b, s.lineSpacing, usv);
589
588
  const fontFamily = str(b, s.fontFamily.toString());
590
589
  const bigFont = str(b, s.bigFontFamily);
591
590
  Duc.DucTextStyle.startDucTextStyle(b);
592
- if (base)
593
- Duc.DucTextStyle.addBaseStyle(b, base);
594
591
  Duc.DucTextStyle.addIsLtr(b, s.isLtr);
595
592
  if (fontFamily)
596
593
  Duc.DucTextStyle.addFontFamily(b, fontFamily);
@@ -879,11 +876,8 @@ function writePlotLayout(b, l, usv) {
879
876
  }
880
877
  function writePlot(b, e, usv) {
881
878
  const stackBase = writeStackElementBase(b, e, usv);
882
- const baseStyle = writeStylesBase(b, e, usv);
883
879
  const plotStyle = (() => {
884
880
  Duc.DucPlotStyle.startDucPlotStyle(b);
885
- if (baseStyle)
886
- Duc.DucPlotStyle.addBaseStyle(b, baseStyle);
887
881
  return Duc.DucPlotStyle.endDucPlotStyle(b);
888
882
  })();
889
883
  const layout = writePlotLayout(b, e.layout, usv);
@@ -910,10 +904,7 @@ function writeView(b, v, usv) {
910
904
  return Duc.DucView.endDucView(b);
911
905
  }
912
906
  function writeViewportStyle(b, s, usv) {
913
- const base = writeStylesBase(b, s, usv);
914
907
  Duc.DucViewportStyle.startDucViewportStyle(b);
915
- if (base)
916
- Duc.DucViewportStyle.addBaseStyle(b, base);
917
908
  Duc.DucViewportStyle.addScaleIndicatorVisible(b, s.scaleIndicatorVisible);
918
909
  return Duc.DucViewportStyle.endDucViewportStyle(b);
919
910
  }
@@ -940,11 +931,8 @@ function writeViewport(b, e, usv) {
940
931
  return Duc.DucViewportElement.endDucViewportElement(b);
941
932
  }
942
933
  function writeXRayStyle(b, s, usv) {
943
- const base = writeStylesBase(b, s, usv);
944
934
  const color = b.createString(s.color);
945
935
  Duc.DucXRayStyle.startDucXRayStyle(b);
946
- if (base)
947
- Duc.DucXRayStyle.addBaseStyle(b, base);
948
936
  Duc.DucXRayStyle.addColor(b, color);
949
937
  return Duc.DucXRayStyle.endDucXRayStyle(b);
950
938
  }
@@ -999,12 +987,9 @@ function writeLeaderContent(b, c, usv) {
999
987
  return Duc.LeaderContent.endLeaderContent(b);
1000
988
  }
1001
989
  function writeLeaderStyle(b, s, usv) {
1002
- const base = writeStylesBase(b, s, usv);
1003
990
  const text = writeTextStyle(b, s.textStyle, usv);
1004
991
  const heads = s.headsOverride ? Duc.DucLeaderStyle.createHeadsOverrideVector(b, s.headsOverride.map((h) => writeHead(b, h, usv))) : undefined;
1005
992
  Duc.DucLeaderStyle.startDucLeaderStyle(b);
1006
- if (base)
1007
- Duc.DucLeaderStyle.addBaseStyle(b, base);
1008
993
  if (heads)
1009
994
  Duc.DucLeaderStyle.addHeadsOverride(b, heads);
1010
995
  if (s.dogleg !== undefined)
@@ -1249,7 +1234,6 @@ function writeFcfDatumDefinition(b, d, usv) {
1249
1234
  return Duc.FCFDatumDefinition.endFCFDatumDefinition(b);
1250
1235
  }
1251
1236
  function writeFcfStyle(b, s, usv) {
1252
- const base = writeStylesBase(b, s, usv);
1253
1237
  const text = writeTextStyle(b, s.textStyle, usv);
1254
1238
  const layout = (() => {
1255
1239
  Duc.FCFLayoutStyle.startFCFLayoutStyle(b);
@@ -1269,8 +1253,6 @@ function writeFcfStyle(b, s, usv) {
1269
1253
  return Duc.FCFDatumStyle.endFCFDatumStyle(b);
1270
1254
  })();
1271
1255
  Duc.DucFeatureControlFrameStyle.startDucFeatureControlFrameStyle(b);
1272
- if (base)
1273
- Duc.DucFeatureControlFrameStyle.addBaseStyle(b, base);
1274
1256
  Duc.DucFeatureControlFrameStyle.addTextStyle(b, text);
1275
1257
  Duc.DucFeatureControlFrameStyle.addLayout(b, layout);
1276
1258
  Duc.DucFeatureControlFrameStyle.addSymbols(b, sym);
@@ -1386,21 +1368,19 @@ function writeTableCellStyle(b, s, usv) {
1386
1368
  Duc.Margins.addLeft(b, getPrecisionValue(s.margins.left, usv));
1387
1369
  const margins = Duc.Margins.endMargins(b);
1388
1370
  Duc.DucTableCellStyle.startDucTableCellStyle(b);
1389
- if (base)
1371
+ if (base) {
1390
1372
  Duc.DucTableCellStyle.addBaseStyle(b, base);
1373
+ }
1391
1374
  Duc.DucTableCellStyle.addTextStyle(b, text);
1392
1375
  Duc.DucTableCellStyle.addMargins(b, margins);
1393
1376
  Duc.DucTableCellStyle.addAlignment(b, s.alignment);
1394
1377
  return Duc.DucTableCellStyle.endDucTableCellStyle(b);
1395
1378
  }
1396
1379
  function writeTableStyle(b, s, usv) {
1397
- const base = writeStylesBase(b, s, usv);
1398
1380
  const header = writeTableCellStyle(b, s.headerRowStyle, usv);
1399
1381
  const dataRow = writeTableCellStyle(b, s.dataRowStyle, usv);
1400
1382
  const dataCol = writeTableCellStyle(b, s.dataColumnStyle, usv);
1401
1383
  Duc.DucTableStyle.startDucTableStyle(b);
1402
- if (base)
1403
- Duc.DucTableStyle.addBaseStyle(b, base);
1404
1384
  Duc.DucTableStyle.addFlowDirection(b, s.flowDirection);
1405
1385
  Duc.DucTableStyle.addHeaderRowStyle(b, header);
1406
1386
  Duc.DucTableStyle.addDataRowStyle(b, dataRow);
@@ -2369,13 +2349,13 @@ function serializeExternalFiles(builder, files, usv) {
2369
2349
  export const DUC_SCHEMA_VERSION = (typeof process !== "undefined" && process.env && process.env.DUC_SCHEMA_VERSION) ||
2370
2350
  (typeof import.meta !== "undefined" && import.meta.env && import.meta.env.DUC_SCHEMA_VERSION) ||
2371
2351
  "0.0.0";
2372
- export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, useScopedValues = false, passThroughElementIds = []) {
2352
+ export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, useScopedValues = false, passThroughElementIds = [], restoreConfig = {}) {
2373
2353
  const builder = new flatbuffers.Builder(1024);
2374
2354
  const sanitized = restore(data, {
2375
2355
  refreshDimensions: false,
2376
2356
  syncInvalidIndices: (elements) => elements,
2377
2357
  passThroughElementIds
2378
- });
2358
+ }, restoreConfig);
2379
2359
  const typeOffset = builder.createString(EXPORT_DATA_TYPES.duc);
2380
2360
  const sourceOffset = builder.createString(typeof window !== "undefined" ? window.location.origin : "unknown");
2381
2361
  const versionOffset = builder.createString(DUC_SCHEMA_VERSION);
@@ -2422,6 +2402,10 @@ export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ..
2422
2402
  const thumbnailOffset = sanitized.thumbnail
2423
2403
  ? builder.createByteVector(sanitized.thumbnail)
2424
2404
  : null;
2405
+ // Serialize id (as string if present)
2406
+ const idOffset = sanitized.id
2407
+ ? builder.createString(sanitized.id)
2408
+ : null;
2425
2409
  Duc.ExportedDataState.startExportedDataState(builder);
2426
2410
  Duc.ExportedDataState.addType(builder, typeOffset);
2427
2411
  Duc.ExportedDataState.addVersion(builder, versionOffset);
@@ -2458,6 +2442,9 @@ export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ..
2458
2442
  if (thumbnailOffset) {
2459
2443
  Duc.ExportedDataState.addThumbnail(builder, thumbnailOffset);
2460
2444
  }
2445
+ if (idOffset) {
2446
+ Duc.ExportedDataState.addId(builder, idOffset);
2447
+ }
2461
2448
  const exportedDataStateOffset = Duc.ExportedDataState.endExportedDataState(builder);
2462
2449
  builder.finish(exportedDataStateOffset, "DUC_");
2463
2450
  return builder.asUint8Array();
@@ -1,5 +1,5 @@
1
- import { DucElement } from "ducjs/types/elements";
2
- import { CombinedMeasure, SupportedMeasures } from "ducjs/technical/scopes";
1
+ import { DucElement } from "../types/elements";
2
+ import { CombinedMeasure, SupportedMeasures } from "./scopes";
3
3
  /**
4
4
  * Gets translation factor between current scope and element scope
5
5
  */
@@ -1,4 +1,4 @@
1
- import { calculateScope, getTranslationFactor } from "ducjs/technical/scopes";
1
+ import { calculateScope, getTranslationFactor } from "./scopes";
2
2
  /**
3
3
  * Gets translation factor between current scope and element scope
4
4
  */
@@ -1,7 +1,7 @@
1
- import { UNIT_SYSTEM } from "ducjs/flatbuffers/duc";
2
- import { PrecisionValue, RawValue, ScaledZoom, Scope, ScopedValue, ScopedZoomValue, ValueOf } from "ducjs/types";
3
- import { DucPoint } from "ducjs/types/elements";
4
- import { GeometricPoint } from "ducjs/types/geometryTypes";
1
+ import { UNIT_SYSTEM } from "../flatbuffers/duc";
2
+ import { PrecisionValue, RawValue, ScaledZoom, Scope, ScopedValue, ScopedZoomValue, ValueOf } from "../types";
3
+ import { DucPoint } from "../types/elements";
4
+ import { GeometricPoint } from "../types/geometryTypes";
5
5
  export type UnitSystem = ValueOf<typeof UNIT_SYSTEM>;
6
6
  export type ZoomDirection = 'up' | 'down' | 'neutral';
7
7
  export declare const MIN_ZOOM = 1e-32;
@@ -1,4 +1,4 @@
1
- import { UNIT_SYSTEM } from "ducjs/flatbuffers/duc";
1
+ import { UNIT_SYSTEM } from "../flatbuffers/duc";
2
2
  export const MIN_ZOOM = 1e-32;
3
3
  export const MAX_ZOOM = 1e32;
4
4
  export const NEUTRAL_SCOPE = "m";
@@ -1,7 +1,7 @@
1
- import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT } from "ducjs/flatbuffers/duc";
2
- import { UnitSystem } from "ducjs/technical/scopes";
3
- import { DucCommonStyle, DucDimensionStyle, DucDocStyle, DucFeatureControlFrameStyle, DucHatchStyle, DucLeaderStyle, DucStackLikeStyles, DucTableStyle, DucTextStyle, DucUcs, DucView, DucViewportStyle, DucXRayStyle, GridSettings, Identifier, PrecisionValue, Scope, SnapSettings, StrokeStyle } from "ducjs/types";
4
- import { ValueOf } from "ducjs/types/utility-types";
1
+ import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT } from "../flatbuffers/duc";
2
+ import { UnitSystem } from "./scopes";
3
+ import { DucCommonStyle, DucDimensionStyle, DucDocStyle, DucFeatureControlFrameStyle, DucHatchStyle, DucLeaderStyle, DucStackLikeStyles, DucTableStyle, DucTextStyle, DucUcs, DucView, DucViewportStyle, DucXRayStyle, GridSettings, Identifier, PrecisionValue, Scope, SnapSettings, StrokeStyle } from "../types";
4
+ import { ValueOf } from "../types/utility-types";
5
5
  export declare const PREDEFINED_STANDARDS: {
6
6
  readonly DUC: "duc";
7
7
  readonly ISO_25300: "iso-25300-2013";
@@ -1,10 +1,10 @@
1
1
  export * from "./typeChecks";
2
- import { BEZIER_MIRRORING, BLENDING, BLOCK_ATTACHMENT, BOOLEAN_OPERATION, COLUMN_TYPE, DATUM_BRACKET_STYLE, DATUM_TARGET_TYPE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, ELEMENT_CONTENT_PREFERENCE, FEATURE_MODIFIER, GDT_SYMBOL, HATCH_STYLE, IMAGE_STATUS, LINE_HEAD, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_ALIGN, TEXT_FIELD_SOURCE_PROPERTY, TEXT_FIELD_SOURCE_TYPE, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_TYPE, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "ducjs/flatbuffers/duc";
3
- import { Standard, StandardUnits } from "ducjs/technical/standards";
4
- import { DucView, PrecisionValue, Scope } from "ducjs/types";
5
- import { Axis, GeometricPoint, Percentage, Radian, ScaleFactor } from "ducjs/types/geometryTypes";
6
- import { MakeBrand, MarkNonNullable, MarkOptional, Merge, ValueOf } from "ducjs/types/utility-types";
7
- import { FONT_FAMILY, FREEDRAW_EASINGS } from "ducjs/utils/constants";
2
+ import { BEZIER_MIRRORING, BLENDING, BLOCK_ATTACHMENT, BOOLEAN_OPERATION, COLUMN_TYPE, DATUM_BRACKET_STYLE, DATUM_TARGET_TYPE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, ELEMENT_CONTENT_PREFERENCE, FEATURE_MODIFIER, GDT_SYMBOL, HATCH_STYLE, IMAGE_STATUS, LINE_HEAD, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_ALIGN, TEXT_FIELD_SOURCE_PROPERTY, TEXT_FIELD_SOURCE_TYPE, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_TYPE, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "../../flatbuffers/duc";
3
+ import { Standard, StandardUnits } from "../../technical/standards";
4
+ import { DucView, PrecisionValue, Scope } from "..";
5
+ import { Axis, GeometricPoint, Percentage, Radian, ScaleFactor } from "../geometryTypes";
6
+ import { MakeBrand, MarkNonNullable, MarkOptional, Merge, ValueOf } from "../utility-types";
7
+ import { FONT_FAMILY, FREEDRAW_EASINGS } from "../../utils/constants";
8
8
  /**
9
9
  * Base styles that all elements share
10
10
  */
@@ -341,7 +341,7 @@ export type DucTableCellStyle = _DucElementStylesBase & {
341
341
  * It sets the defaults for rows, columns, and cells, which can be
342
342
  * individually overridden.
343
343
  */
344
- export type DucTableStyle = _DucElementStylesBase & {
344
+ export type DucTableStyle = {
345
345
  /** The direction in which new rows are added */
346
346
  flowDirection: TableFlowDirection;
347
347
  /** Default style for the header row(s) */
@@ -453,7 +453,7 @@ export type TextAlign = ValueOf<typeof TEXT_ALIGN>;
453
453
  export type VerticalAlign = ValueOf<typeof VERTICAL_ALIGN>;
454
454
  export type LineSpacingType = ValueOf<typeof LINE_SPACING_TYPE>;
455
455
  export type TextFieldSourceProperty = ValueOf<typeof TEXT_FIELD_SOURCE_PROPERTY>;
456
- export type DucTextStyle = _DucElementStylesBase & {
456
+ export type DucTextStyle = {
457
457
  /**
458
458
  * Whether the text is left-to-right or right-to-left
459
459
  * @default true
@@ -845,7 +845,7 @@ export type ViewportShadePlot = ValueOf<typeof VIEWPORT_SHADE_PLOT>;
845
845
  * This is the style for the viewport element
846
846
  * Grid settings, UCS, Snapping and more can be overridden through the overrideStandard property from the _DucStackElementBase
847
847
  */
848
- export type DucViewportStyle = _DucElementStylesBase & {
848
+ export type DucViewportStyle = {
849
849
  scaleIndicatorVisible: boolean;
850
850
  };
851
851
  export type DucViewportElement = _DucLinearElementBase & _DucStackBase & DucViewportStyle & {
@@ -873,7 +873,7 @@ export type PlotLayout = {
873
873
  left: PrecisionValue;
874
874
  };
875
875
  };
876
- export type DucPlotStyle = _DucElementStylesBase & {};
876
+ export type DucPlotStyle = {};
877
877
  /**
878
878
  * A DucPlotElement represents a finite layout or "paper space" within the infinite canvas.
879
879
  * It serves as a container for viewports and other annotations, defining the final
@@ -885,7 +885,7 @@ export type DucPlotElement = _DucStackElementBase & DucPlotStyle & {
885
885
  /** The layout definition for this plot, including paper size and margins. */
886
886
  layout: PlotLayout;
887
887
  };
888
- export type DucXRayStyle = _DucElementStylesBase & {
888
+ export type DucXRayStyle = {
889
889
  /**
890
890
  * The color of the x-ray
891
891
  */
@@ -906,7 +906,7 @@ export type BlockAttachment = ValueOf<typeof BLOCK_ATTACHMENT>;
906
906
  /**
907
907
  * Defines the visual appearance and behavior of a leader.
908
908
  */
909
- export type DucLeaderStyle = _DucElementStylesBase & {
909
+ export type DucLeaderStyle = {
910
910
  /**
911
911
  * Override the heads of the leader
912
912
  * The tuple represents [startHead, endHead]
@@ -1161,7 +1161,7 @@ export type FeatureControlFrameSegment = {
1161
1161
  * Defines the visual appearance of a Feature Control Frame.
1162
1162
  * This can be stored in a style library and reused.
1163
1163
  */
1164
- export type DucFeatureControlFrameStyle = _DucElementStylesBase & {
1164
+ export type DucFeatureControlFrameStyle = {
1165
1165
  /** The base text style for numbers and letters within the frame */
1166
1166
  textStyle: DucTextStyle;
1167
1167
  /** Layout and spacing properties */
@@ -1,7 +1,7 @@
1
- import type { ElementOrToolType } from "ducjs/types";
2
- import type { MarkNonNullable } from "ducjs/types/utility-types";
3
- import { Bounds, LineSegment, TuplePoint } from "ducjs/types/geometryTypes";
4
- import type { DucArrowElement, DucBindableElement, DucElbowArrowElement, DucElement, DucElementType, DucEmbeddableElement, DucFlowchartNodeElement, DucFrameElement, DucFrameLikeElement, DucFreeDrawElement, DucImageElement, DucLinearElement, DucTableElement, DucPointBinding, DucTextContainer, DucTextElement, DucTextElementWithContainer, FixedPointBinding, InitializedDucImageElement, DucNonSelectionElement, DucEllipseElement, DucPolygonElement, DucBlockInstanceElement, NonDeleted, DucIframeLikeElement } from "ducjs/types/elements";
1
+ import type { ElementOrToolType } from "..";
2
+ import type { MarkNonNullable } from "../utility-types";
3
+ import { Bounds, LineSegment, TuplePoint } from "../geometryTypes";
4
+ import type { DucArrowElement, DucBindableElement, DucElbowArrowElement, DucElement, DucElementType, DucEmbeddableElement, DucFlowchartNodeElement, DucFrameElement, DucFrameLikeElement, DucFreeDrawElement, DucImageElement, DucLinearElement, DucPlotElement, DucTableElement, DucPointBinding, DucTextContainer, DucTextElement, DucTextElementWithContainer, FixedPointBinding, InitializedDucImageElement, DucNonSelectionElement, DucEllipseElement, DucPolygonElement, DucBlockInstanceElement, NonDeleted, DucIframeLikeElement } from "./";
5
5
  export declare const isInitializedImageElement: (element: DucElement | null) => element is InitializedDucImageElement;
6
6
  export declare const isImageElement: (element: DucElement | null) => element is DucImageElement;
7
7
  export declare const isEmbeddableElement: (element: DucElement | null | undefined) => element is DucEmbeddableElement;
@@ -9,6 +9,7 @@ export declare const isTableElement: (element: DucElement | null) => element is
9
9
  export declare const isIframeLikeElement: (element: DucElement | null) => element is DucIframeLikeElement;
10
10
  export declare const isTextElement: (element: DucElement | null) => element is DucTextElement;
11
11
  export declare const isFrameElement: (element: DucElement | null) => element is DucFrameElement;
12
+ export declare const isPlotElement: (element: DucElement | null) => element is DucPlotElement;
12
13
  export declare const isFrameLikeElement: (element: DucElement | null) => element is DucFrameLikeElement;
13
14
  export declare const isFreeDrawElement: (element?: DucElement | null) => element is DucFreeDrawElement;
14
15
  export declare const isEllipseElement: (element?: DucElement | null) => element is DucEllipseElement;
@@ -1,4 +1,4 @@
1
- import { assertNever } from "ducjs/utils";
1
+ import { assertNever } from "../../utils";
2
2
  export const isInitializedImageElement = (element) => {
3
3
  return !!element && element.type === "image" && !!element.fileId;
4
4
  };
@@ -22,9 +22,12 @@ export const isTextElement = (element) => {
22
22
  export const isFrameElement = (element) => {
23
23
  return element != null && element.type === "frame";
24
24
  };
25
+ export const isPlotElement = (element) => {
26
+ return element != null && element.type === "plot";
27
+ };
25
28
  export const isFrameLikeElement = (element) => {
26
29
  return (element != null &&
27
- (element.type === "frame"));
30
+ (element.type === "frame" || element.type === "plot"));
28
31
  };
29
32
  export const isFreeDrawElement = (element) => {
30
33
  return element != null && isFreeDrawElementType(element.type);
@@ -1,5 +1,5 @@
1
- import { AXIS } from "ducjs/flatbuffers/duc";
2
- import { ScopedValue, ValueOf } from "ducjs/types";
1
+ import { AXIS } from "../flatbuffers/duc";
2
+ import { ScopedValue, ValueOf } from "./";
3
3
  /**
4
4
  * Axis such as X, Y, Z
5
5
  */