ducjs 4.0.4 → 4.2.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 (122) hide show
  1. package/dist/duc_locator_wasm.d.ts +48 -0
  2. package/dist/duc_locator_wasm.js +296 -0
  3. package/dist/duc_locator_wasm_bg.wasm +0 -0
  4. package/dist/duc_locator_wasm_bg.wasm.d.ts +13 -0
  5. package/dist/ducjs_wasi.wasm +0 -0
  6. package/dist/ducjs_wasm.d.ts +14 -2
  7. package/dist/ducjs_wasm.js +96 -8
  8. package/dist/ducjs_wasm_bg.wasm +0 -0
  9. package/dist/ducjs_wasm_bg.wasm.d.ts +6 -2
  10. package/dist/index.d.ts +4 -1
  11. package/dist/index.js +4 -1
  12. package/dist/locator-runtime.d.ts +4 -0
  13. package/dist/locator-runtime.js +7 -0
  14. package/dist/restore/index.d.ts +1 -0
  15. package/dist/restore/index.js +1 -0
  16. package/dist/restore/restoreDataState.d.ts +13 -24
  17. package/dist/restore/restoreDataState.js +49 -83
  18. package/dist/restore/restoreElements.d.ts +10 -15
  19. package/dist/restore/restoreElements.js +128 -125
  20. package/dist/restore/updateModelCode.d.ts +11 -0
  21. package/dist/restore/updateModelCode.js +63 -0
  22. package/dist/thumbnails/bounds.d.ts +21 -0
  23. package/dist/thumbnails/bounds.js +84 -0
  24. package/dist/thumbnails/browserRunner.d.ts +60 -0
  25. package/dist/thumbnails/browserRunner.js +446 -0
  26. package/dist/thumbnails/cameraPresets.d.ts +47 -0
  27. package/dist/thumbnails/cameraPresets.js +222 -0
  28. package/dist/thumbnails/cli.d.ts +2 -0
  29. package/dist/thumbnails/cli.js +102 -0
  30. package/dist/thumbnails/index.d.ts +11 -0
  31. package/dist/thumbnails/index.js +11 -0
  32. package/dist/thumbnails/lib/clientBundle.min.js +10427 -0
  33. package/dist/thumbnails/lib/clientEntry.d.ts +3 -0
  34. package/dist/thumbnails/lib/clientEntry.js +8 -0
  35. package/dist/thumbnails/lib/clippingUtils.d.ts +10 -0
  36. package/dist/thumbnails/lib/clippingUtils.js +3 -0
  37. package/dist/thumbnails/lib/defaultModelColor.d.ts +3 -0
  38. package/dist/thumbnails/lib/defaultModelColor.js +22 -0
  39. package/dist/thumbnails/lib/index.d.ts +12 -0
  40. package/dist/thumbnails/lib/index.js +12 -0
  41. package/dist/thumbnails/lib/mapViewerStateToOptions.d.ts +34 -0
  42. package/dist/thumbnails/lib/mapViewerStateToOptions.js +69 -0
  43. package/dist/thumbnails/lib/offscreen-dxf-thumbnail.d.ts +16 -0
  44. package/dist/thumbnails/lib/offscreen-dxf-thumbnail.js +173 -0
  45. package/dist/thumbnails/lib/offscreen-model-thumbnail.d.ts +16 -0
  46. package/dist/thumbnails/lib/offscreen-model-thumbnail.js +209 -0
  47. package/dist/thumbnails/lib/parametricClip.d.ts +18 -0
  48. package/dist/thumbnails/lib/parametricClip.js +177 -0
  49. package/dist/thumbnails/lib/parametricShapes.d.ts +1 -0
  50. package/dist/thumbnails/lib/parametricShapes.js +75 -0
  51. package/dist/thumbnails/lib/parametricViewerState.d.ts +26 -0
  52. package/dist/thumbnails/lib/parametricViewerState.js +198 -0
  53. package/dist/thumbnails/lib/thumbnail-camera-fit.d.ts +6 -0
  54. package/dist/thumbnails/lib/thumbnail-camera-fit.js +292 -0
  55. package/dist/thumbnails/lib/thumbnail-capture.d.ts +23 -0
  56. package/dist/thumbnails/lib/thumbnail-capture.js +161 -0
  57. package/dist/thumbnails/lib/thumbnail-visibility.d.ts +12 -0
  58. package/dist/thumbnails/lib/thumbnail-visibility.js +97 -0
  59. package/dist/thumbnails/lib/viewerGrid.d.ts +13 -0
  60. package/dist/thumbnails/lib/viewerGrid.js +57 -0
  61. package/dist/thumbnails/modelCache.d.ts +56 -0
  62. package/dist/thumbnails/modelCache.js +165 -0
  63. package/dist/thumbnails/modelOutputArtifact.d.ts +19 -0
  64. package/dist/thumbnails/modelOutputArtifact.js +87 -0
  65. package/dist/thumbnails/render.d.ts +45 -0
  66. package/dist/thumbnails/render.js +162 -0
  67. package/dist/thumbnails/templates.d.ts +16 -0
  68. package/dist/thumbnails/templates.js +786 -0
  69. package/dist/thumbnails/tessellator.d.ts +33 -0
  70. package/dist/thumbnails/tessellator.js +349 -0
  71. package/dist/thumbnails/types.d.ts +233 -0
  72. package/dist/thumbnails/types.js +1 -0
  73. package/dist/thumbnails/worker.d.ts +10 -0
  74. package/dist/thumbnails/worker.js +119 -0
  75. package/dist/transform.d.ts +1 -1
  76. package/dist/transform.js +20 -22
  77. package/dist/types/elements/index.d.ts +22 -28
  78. package/dist/types/elements/index.js +0 -1
  79. package/dist/types/geometry.types.d.ts +5 -5
  80. package/dist/types/index.d.ts +13 -59
  81. package/dist/types/index.js +0 -1
  82. package/dist/types/issues.types.d.ts +1 -2
  83. package/dist/utils/bounds.d.ts +10 -11
  84. package/dist/utils/bounds.js +105 -84
  85. package/dist/utils/constants.d.ts +5 -7
  86. package/dist/utils/constants.js +10 -15
  87. package/dist/utils/elements/freedrawElement.js +6 -3
  88. package/dist/utils/elements/index.d.ts +2 -6
  89. package/dist/utils/elements/index.js +4 -9
  90. package/dist/utils/elements/linearElement.d.ts +12 -14
  91. package/dist/utils/elements/linearElement.js +81 -66
  92. package/dist/utils/elements/newElement.d.ts +37 -22
  93. package/dist/utils/elements/newElement.js +70 -64
  94. package/dist/utils/elements/textElement.d.ts +34 -35
  95. package/dist/utils/elements/textElement.js +79 -83
  96. package/dist/utils/index.d.ts +1 -1
  97. package/dist/utils/index.js +1 -1
  98. package/dist/utils/locator.d.ts +43 -0
  99. package/dist/utils/locator.js +112 -0
  100. package/dist/utils/math/bbox.d.ts +1 -2
  101. package/dist/utils/math/geometry.js +5 -4
  102. package/dist/utils/math/index.d.ts +13 -17
  103. package/dist/utils/math/index.js +53 -41
  104. package/dist/utils/math/random.js +7 -2
  105. package/dist/utils/normalize.d.ts +5 -5
  106. package/dist/utils/normalize.js +15 -10
  107. package/dist/utils/shape.d.ts +3 -4
  108. package/dist/utils/shape.js +64 -48
  109. package/dist/utils/state/index.d.ts +3 -4
  110. package/dist/utils/state/index.js +8 -23
  111. package/dist/wasi.js +38 -12
  112. package/package.json +23 -9
  113. package/dist/technical/index.d.ts +0 -2
  114. package/dist/technical/index.js +0 -2
  115. package/dist/technical/measurements.d.ts +0 -31
  116. package/dist/technical/measurements.js +0 -64
  117. package/dist/technical/scopes.d.ts +0 -261
  118. package/dist/technical/scopes.js +0 -676
  119. package/dist/types/typeChecks.d.ts +0 -5
  120. package/dist/types/typeChecks.js +0 -10
  121. package/dist/utils/traverse.d.ts +0 -30
  122. package/dist/utils/traverse.js +0 -124
@@ -1,46 +1,57 @@
1
1
  import { isArrowElement, isFreeDrawElement, isLinearElement, isTextElement } from "../types/elements/typeChecks";
2
2
  import { getBoundTextElementPosition, getLinearElementAbsoluteCoords } from "./elements/linearElement";
3
3
  import { getCubicBezierBoundingBox, getQuadraticBezierBoundingBox, rescaleLines, rescalePoints, rotate } from "./math";
4
- export const getElementAbsoluteCoords = (element, elementsMap, currentScope, includeBoundText = false, returnUnrotatedBoundsOnly = true) => {
4
+ const toNum = (v) => { var _a; return typeof v === "number" ? v : ((_a = v === null || v === void 0 ? void 0 : v.value) !== null && _a !== void 0 ? _a : 0); };
5
+ export const getElementAbsoluteCoords = (element, elementsMap, includeBoundText = false, returnUnrotatedBoundsOnly = true) => {
5
6
  if (isFreeDrawElement(element)) {
6
7
  return getFreeDrawElementAbsoluteCoords(element);
7
8
  }
8
9
  else if (isLinearElement(element)) {
9
- return getLinearElementAbsoluteCoords(element, elementsMap, includeBoundText, currentScope, returnUnrotatedBoundsOnly);
10
+ return getLinearElementAbsoluteCoords(element, elementsMap, includeBoundText, returnUnrotatedBoundsOnly);
10
11
  }
11
12
  else if (isTextElement(element)) {
12
13
  const container = elementsMap
13
14
  ? getContainerElement(element, elementsMap)
14
15
  : null;
15
16
  if (isArrowElement(container)) {
16
- const coords = getBoundTextElementPosition(container, element, elementsMap, currentScope);
17
+ const coords = getBoundTextElementPosition(container, element, elementsMap);
17
18
  if (coords === null) {
19
+ const ex = toNum(element.x);
20
+ const ey = toNum(element.y);
21
+ const ew = toNum(element.width);
22
+ const eh = toNum(element.height);
18
23
  return [
19
- element.x.scoped,
20
- element.y.scoped,
21
- element.x.scoped + element.width.scoped,
22
- element.y.scoped + element.height.scoped,
23
- element.x.scoped + element.width.scoped / 2,
24
- element.y.scoped + element.height.scoped / 2,
24
+ ex,
25
+ ey,
26
+ (ex + ew),
27
+ (ey + eh),
28
+ (ex + ew / 2),
29
+ (ey + eh / 2),
25
30
  ];
26
31
  }
32
+ const ew = toNum(element.width);
33
+ const eh = toNum(element.height);
27
34
  return [
28
35
  coords.x,
29
36
  coords.y,
30
- coords.x + element.width.scoped,
31
- coords.y + element.height.scoped,
32
- coords.x + element.width.scoped / 2,
33
- coords.y + element.height.scoped / 2,
37
+ (coords.x + ew),
38
+ (coords.y + eh),
39
+ (coords.x + ew / 2),
40
+ (coords.y + eh / 2),
34
41
  ];
35
42
  }
36
43
  }
44
+ const ex = toNum(element.x);
45
+ const ey = toNum(element.y);
46
+ const ew = toNum(element.width);
47
+ const eh = toNum(element.height);
37
48
  return [
38
- element.x.scoped,
39
- element.y.scoped,
40
- element.x.scoped + element.width.scoped,
41
- element.y.scoped + element.height.scoped,
42
- element.x.scoped + element.width.scoped / 2,
43
- element.y.scoped + element.height.scoped / 2,
49
+ ex,
50
+ ey,
51
+ (ex + ew),
52
+ (ey + eh),
53
+ (ex + ew / 2),
54
+ (ey + eh / 2),
44
55
  ];
45
56
  };
46
57
  /**
@@ -56,10 +67,10 @@ export const calculatePointsBounds = (points) => {
56
67
  };
57
68
  }
58
69
  return points.reduce((limits, { x, y }) => ({
59
- minX: Math.min(limits.minX, x.scoped),
60
- minY: Math.min(limits.minY, y.scoped),
61
- maxX: Math.max(limits.maxX, x.scoped),
62
- maxY: Math.max(limits.maxY, y.scoped),
70
+ minX: Math.min(limits.minX, toNum(x)),
71
+ minY: Math.min(limits.minY, toNum(y)),
72
+ maxX: Math.max(limits.maxX, toNum(x)),
73
+ maxY: Math.max(limits.maxY, toNum(y)),
63
74
  }), {
64
75
  minX: Infinity,
65
76
  minY: Infinity,
@@ -90,10 +101,10 @@ export const calculateGeometricPointsBounds = (points) => {
90
101
  maxY = Math.max(maxY, y);
91
102
  }
92
103
  return {
93
- minX: minX,
94
- minY: minY,
95
- maxX: maxX,
96
- maxY: maxY,
104
+ minX,
105
+ minY,
106
+ maxX,
107
+ maxY,
97
108
  };
98
109
  };
99
110
  /**
@@ -116,10 +127,10 @@ export const processBezierCurveBounds = (points, lines, initialBounds) => {
116
127
  continue;
117
128
  if (startHandle && endHandle) {
118
129
  // Cubic Bezier curve segment (both handles present)
119
- const p0 = { x: startPoint.x.scoped, y: startPoint.y.scoped };
120
- const p1 = { x: startHandle.x.scoped, y: startHandle.y.scoped };
121
- const p2 = { x: endHandle.x.scoped, y: endHandle.y.scoped };
122
- const p3 = { x: endPoint.x.scoped, y: endPoint.y.scoped };
130
+ const p0 = { x: toNum(startPoint.x), y: toNum(startPoint.y) };
131
+ const p1 = { x: toNum(startHandle.x), y: toNum(startHandle.y) };
132
+ const p2 = { x: toNum(endHandle.x), y: toNum(endHandle.y) };
133
+ const p3 = { x: toNum(endPoint.x), y: toNum(endPoint.y) };
123
134
  const bbox = getCubicBezierBoundingBox(p0, p1, p2, p3);
124
135
  minX = Math.min(minX, bbox.minX);
125
136
  minY = Math.min(minY, bbox.minY);
@@ -129,9 +140,9 @@ export const processBezierCurveBounds = (points, lines, initialBounds) => {
129
140
  else if (startHandle || endHandle) {
130
141
  // Quadratic Bezier curve segment (one handle present)
131
142
  const controlHandle = startHandle || endHandle;
132
- const p0 = { x: startPoint.x.scoped, y: startPoint.y.scoped };
133
- const p1 = { x: controlHandle.x.scoped, y: controlHandle.y.scoped };
134
- const p2 = { x: endPoint.x.scoped, y: endPoint.y.scoped };
143
+ const p0 = { x: toNum(startPoint.x), y: toNum(startPoint.y) };
144
+ const p1 = { x: toNum(controlHandle.x), y: toNum(controlHandle.y) };
145
+ const p2 = { x: toNum(endPoint.x), y: toNum(endPoint.y) };
135
146
  const bbox = getQuadraticBezierBoundingBox(p0, p1, p2);
136
147
  minX = Math.min(minX, bbox.minX);
137
148
  minY = Math.min(minY, bbox.minY);
@@ -163,24 +174,26 @@ export const processRotatedAbsoluteBezierBounds = (points, lines, elementX, elem
163
174
  const endPoint = points[endIndex];
164
175
  if (!startPoint || !endPoint)
165
176
  continue;
177
+ const elX = toNum(elementX);
178
+ const elY = toNum(elementY);
166
179
  // Convert to absolute coordinates
167
180
  const absoluteStartPoint = {
168
- x: elementX + startPoint.x.scoped,
169
- y: elementY + startPoint.y.scoped,
181
+ x: elX + toNum(startPoint.x),
182
+ y: elY + toNum(startPoint.y),
170
183
  };
171
184
  const absoluteEndPoint = {
172
- x: elementX + endPoint.x.scoped,
173
- y: elementY + endPoint.y.scoped,
185
+ x: elX + toNum(endPoint.x),
186
+ y: elY + toNum(endPoint.y),
174
187
  };
175
188
  if (startHandle && endHandle) {
176
189
  // Cubic Bezier curve segment
177
190
  const absoluteStartHandle = {
178
- x: elementX + startHandle.x.scoped,
179
- y: elementY + startHandle.y.scoped,
191
+ x: elX + toNum(startHandle.x),
192
+ y: elY + toNum(startHandle.y),
180
193
  };
181
194
  const absoluteEndHandle = {
182
- x: elementX + endHandle.x.scoped,
183
- y: elementY + endHandle.y.scoped,
195
+ x: elX + toNum(endHandle.x),
196
+ y: elY + toNum(endHandle.y),
184
197
  };
185
198
  const p0 = rotate(absoluteStartPoint.x, absoluteStartPoint.y, centerX, centerY, angle);
186
199
  const p1 = rotate(absoluteStartHandle.x, absoluteStartHandle.y, centerX, centerY, angle);
@@ -196,8 +209,8 @@ export const processRotatedAbsoluteBezierBounds = (points, lines, elementX, elem
196
209
  // Quadratic Bezier curve segment
197
210
  const controlHandle = startHandle || endHandle;
198
211
  const absoluteControlHandle = {
199
- x: elementX + controlHandle.x.scoped,
200
- y: elementY + controlHandle.y.scoped,
212
+ x: elX + toNum(controlHandle.x),
213
+ y: elY + toNum(controlHandle.y),
201
214
  };
202
215
  const p0 = rotate(absoluteStartPoint.x, absoluteStartPoint.y, centerX, centerY, angle);
203
216
  const p1 = rotate(absoluteControlHandle.x, absoluteControlHandle.y, centerX, centerY, angle);
@@ -238,14 +251,14 @@ export const processRelativeBezierBounds = (points, lines, initialBounds) => {
238
251
  const p1 = points[p1_idx];
239
252
  const p2 = points[p2_idx];
240
253
  if (line[0].handle || line[1].handle) {
241
- const p0 = { x: p1.x.scoped, y: p1.y.scoped };
242
- const p3 = { x: p2.x.scoped, y: p2.y.scoped };
254
+ const p0 = { x: toNum(p1.x), y: toNum(p1.y) };
255
+ const p3 = { x: toNum(p2.x), y: toNum(p2.y) };
243
256
  const h1 = line[0].handle;
244
257
  const h2 = line[1].handle;
245
258
  try {
246
259
  if (h1 && h2) {
247
- const cp1 = { x: h1.x.scoped, y: h1.y.scoped };
248
- const cp2 = { x: h2.x.scoped, y: h2.y.scoped };
260
+ const cp1 = { x: toNum(h1.x), y: toNum(h1.y) };
261
+ const cp2 = { x: toNum(h2.x), y: toNum(h2.y) };
249
262
  const bbox = getCubicBezierBoundingBox(p0, cp1, cp2, p3);
250
263
  minX = Math.min(minX, bbox.minX);
251
264
  minY = Math.min(minY, bbox.minY);
@@ -253,7 +266,7 @@ export const processRelativeBezierBounds = (points, lines, initialBounds) => {
253
266
  maxY = Math.max(maxY, bbox.maxY);
254
267
  }
255
268
  else if (h1) {
256
- const cp1 = { x: h1.x.scoped, y: h1.y.scoped };
269
+ const cp1 = { x: toNum(h1.x), y: toNum(h1.y) };
257
270
  const bbox = getQuadraticBezierBoundingBox(p0, cp1, p3);
258
271
  minX = Math.min(minX, bbox.minX);
259
272
  minY = Math.min(minY, bbox.minY);
@@ -261,7 +274,7 @@ export const processRelativeBezierBounds = (points, lines, initialBounds) => {
261
274
  maxY = Math.max(maxY, bbox.maxY);
262
275
  }
263
276
  else if (h2) {
264
- const cp2 = { x: h2.x.scoped, y: h2.y.scoped };
277
+ const cp2 = { x: toNum(h2.x), y: toNum(h2.y) };
265
278
  const bbox = getQuadraticBezierBoundingBox(p0, cp2, p3);
266
279
  minX = Math.min(minX, bbox.minX);
267
280
  minY = Math.min(minY, bbox.minY);
@@ -290,16 +303,18 @@ export const calculateShapeBounds = (points, lines) => {
290
303
  */
291
304
  export const calculatePointsBoundsWithCenter = (points) => {
292
305
  const bounds = calculatePointsBounds(points);
293
- return Object.assign(Object.assign({}, bounds), { cx: ((bounds.maxX + bounds.minX) / 2), cy: ((bounds.maxY + bounds.minY) / 2) });
306
+ return Object.assign(Object.assign({}, bounds), { cx: (bounds.maxX + bounds.minX) / 2, cy: (bounds.maxY + bounds.minY) / 2 });
294
307
  };
295
308
  export const getElementPointsCoords = (element, points) => {
296
- var _a, _b, _c;
309
+ var _a, _b;
310
+ const ex = toNum(element.x);
311
+ const ey = toNum(element.y);
297
312
  if (!points || !Array.isArray(points) || points.length === 0) {
298
313
  return [
299
- element.x.scoped,
300
- element.y.scoped,
301
- element.x.scoped,
302
- element.y.scoped,
314
+ ex,
315
+ ey,
316
+ ex,
317
+ ey,
303
318
  ];
304
319
  }
305
320
  let minX = Infinity;
@@ -308,10 +323,10 @@ export const getElementPointsCoords = (element, points) => {
308
323
  let maxY = -Infinity;
309
324
  // First, include all the actual points (these are always on the path)
310
325
  for (const point of points) {
311
- minX = Math.min(minX, point.x.scoped);
312
- minY = Math.min(minY, point.y.scoped);
313
- maxX = Math.max(maxX, point.x.scoped);
314
- maxY = Math.max(maxY, point.y.scoped);
326
+ minX = Math.min(minX, toNum(point.x));
327
+ minY = Math.min(minY, toNum(point.y));
328
+ maxX = Math.max(maxX, toNum(point.x));
329
+ maxY = Math.max(maxY, toNum(point.y));
315
330
  }
316
331
  const lines = element.lines || [];
317
332
  // Use the shared utility for relative Bezier bounds calculation
@@ -321,17 +336,17 @@ export const getElementPointsCoords = (element, points) => {
321
336
  maxX = bezierBounds.maxX;
322
337
  maxY = bezierBounds.maxY;
323
338
  // Account for stroke width
324
- const strokeWidth = ((_c = (_b = (_a = element.stroke) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.width) === null || _c === void 0 ? void 0 : _c.scoped) || 0;
339
+ const strokeWidth = toNum((_b = (_a = element.stroke) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.width) || 0;
325
340
  const strokeOffset = strokeWidth / 2;
326
341
  minX -= strokeOffset;
327
342
  minY -= strokeOffset;
328
343
  maxX += strokeOffset;
329
344
  maxY += strokeOffset;
330
345
  return [
331
- (minX + element.x.scoped),
332
- (minY + element.y.scoped),
333
- (maxX + element.x.scoped),
334
- (maxY + element.y.scoped),
346
+ (minX + ex),
347
+ (minY + ey),
348
+ (maxX + ex),
349
+ (maxY + ey),
335
350
  ];
336
351
  };
337
352
  export const getContainerElement = (element, elementsMap) => {
@@ -349,11 +364,13 @@ export const getBoundsFromPoints = (points) => {
349
364
  return [bounds.minX, bounds.minY, bounds.maxX, bounds.maxY];
350
365
  };
351
366
  export const getFreeDrawElementAbsoluteCoords = (element) => {
352
- const [minX, minY, maxX, maxY] = getBoundsFromPoints(element.points.map((p) => ({ x: p.x.scoped, y: p.y.scoped })));
353
- const x1 = minX + element.x.scoped;
354
- const y1 = minY + element.y.scoped;
355
- const x2 = maxX + element.x.scoped;
356
- const y2 = maxY + element.y.scoped;
367
+ const [minX, minY, maxX, maxY] = getBoundsFromPoints(element.points.map((p) => ({ x: toNum(p.x), y: toNum(p.y) })));
368
+ const ex = toNum(element.x);
369
+ const ey = toNum(element.y);
370
+ const x1 = minX + ex;
371
+ const y1 = minY + ey;
372
+ const x2 = maxX + ex;
373
+ const y2 = maxY + ey;
357
374
  return [
358
375
  x1,
359
376
  y1,
@@ -380,34 +397,38 @@ export const getBoundTextElement = (element, elementsMap) => {
380
397
  }
381
398
  return null;
382
399
  };
383
- export const getResizedElementAbsoluteCoords = (element, nextWidth, nextHeight, normalizePoints, currentScope) => {
400
+ export const getResizedElementAbsoluteCoords = (element, nextWidth, nextHeight, normalizePoints) => {
401
+ const ex = toNum(element.x);
402
+ const ey = toNum(element.y);
403
+ const nw = toNum(nextWidth);
404
+ const nh = toNum(nextHeight);
384
405
  if (!(isLinearElement(element) || isFreeDrawElement(element))) {
385
406
  return [
386
- element.x.scoped,
387
- element.y.scoped,
388
- (element.x.scoped + nextWidth),
389
- (element.y.scoped + nextHeight),
407
+ ex,
408
+ ey,
409
+ (ex + nw),
410
+ (ey + nh),
390
411
  ];
391
412
  }
392
- const pointsAfterYRescale = rescalePoints("y", nextHeight, element.points, normalizePoints, element.scope, currentScope);
393
- const points = rescalePoints("x", nextWidth, pointsAfterYRescale, normalizePoints, element.scope, currentScope);
413
+ const pointsAfterYRescale = rescalePoints("y", nextHeight, element.points, normalizePoints);
414
+ const points = rescalePoints("x", nextWidth, pointsAfterYRescale, normalizePoints);
394
415
  if (isFreeDrawElement(element)) {
395
- const bounds = getBoundsFromPoints(points.map((p) => ({ x: p.x.scoped, y: p.y.scoped })));
416
+ const bounds = getBoundsFromPoints(points.map((p) => ({ x: toNum(p.x), y: toNum(p.y) })));
396
417
  const [minX, minY, maxX, maxY] = bounds;
397
418
  return [
398
- (minX + element.x.scoped),
399
- (minY + element.y.scoped),
400
- (maxX + element.x.scoped),
401
- (maxY + element.y.scoped),
419
+ (minX + ex),
420
+ (minY + ey),
421
+ (maxX + ex),
422
+ (maxY + ey),
402
423
  ];
403
424
  }
404
425
  else {
405
426
  // Linear element
406
427
  const linesAfterYRescale = element.lines
407
- ? rescaleLines("y", nextHeight, element.lines, element.points, normalizePoints, element.scope, currentScope)
428
+ ? rescaleLines("y", nextHeight, element.lines, element.points, normalizePoints)
408
429
  : [];
409
430
  const rescaledLines = element.lines
410
- ? rescaleLines("x", nextWidth, linesAfterYRescale, element.points, normalizePoints, element.scope, currentScope)
431
+ ? rescaleLines("x", nextWidth, linesAfterYRescale, element.points, normalizePoints)
411
432
  : [];
412
433
  return getElementPointsCoords(Object.assign(Object.assign({}, element), { points, lines: rescaledLines }), points);
413
434
  }
@@ -1,6 +1,6 @@
1
- import { MAX_ZOOM, MIN_ZOOM } from "../technical/scopes";
2
- import { RawValue } from "../types";
3
1
  import { DucElement, DucEllipseElement, DucFreeDrawElement, DucTextElement, ElementBackground, ElementStroke, FontFamilyValues } from "../types/elements";
2
+ export declare const MIN_ZOOM = 1e-32;
3
+ export declare const MAX_ZOOM = 1e+32;
4
4
  export declare const COLOR_PALETTE: {
5
5
  readonly transparent: "transparent";
6
6
  readonly black: "#1e1e1e";
@@ -40,7 +40,7 @@ export declare const MIME_TYPES: {
40
40
  readonly avif: "image/avif";
41
41
  readonly jfif: "image/jfif";
42
42
  readonly json: "application/json";
43
- readonly duc: "application/vnd.duc-cad";
43
+ readonly duc: "application/vnd.duc";
44
44
  readonly ducfig: "application/vnd.duc-config";
45
45
  readonly excalidrawlib: "application/vnd.excalidrawlib+json";
46
46
  readonly "excalidraw.svg": "image/svg+xml";
@@ -70,7 +70,7 @@ export declare const EXPORT_DATA_TYPES: {
70
70
  readonly excalidrawLibrary: "excalidrawlib";
71
71
  readonly ducClipboardWithAPI: "duc-api/clipboard";
72
72
  };
73
- export declare const SUPPORTED_DATA_TYPES: ("image/svg+xml" | "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/x-icon" | "image/avif" | "image/jfif" | "application/json" | "application/vnd.duc-cad" | "application/vnd.duc-config" | "application/pdf" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "text/csv" | "text/markdown" | "model/step" | "application/step" | "model/stl")[];
73
+ export declare const SUPPORTED_DATA_TYPES: ("image/svg+xml" | "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/bmp" | "image/x-icon" | "image/avif" | "image/jfif" | "application/json" | "application/vnd.duc" | "application/vnd.duc-config" | "application/pdf" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "text/csv" | "text/markdown" | "model/step" | "application/step" | "model/stl")[];
74
74
  export declare const VERSIONS: {
75
75
  readonly excalidraw: 2;
76
76
  readonly excalidrawLibrary: 2;
@@ -78,7 +78,6 @@ export declare const VERSIONS: {
78
78
  export declare const DEFAULT_ZOOM_STEP = 0.1;
79
79
  export declare const MIN_ZOOM_STEP = 1e-7;
80
80
  export declare const MAX_ZOOM_STEP = 5;
81
- export { MAX_ZOOM, MIN_ZOOM };
82
81
  export declare const BOUND_TEXT_PADDING = 5;
83
82
  export declare const ARROW_LABEL_WIDTH_FRACTION = 0.7;
84
83
  export declare const ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO = 11;
@@ -148,7 +147,6 @@ export declare const DEFAULT_ELEMENT_PROPS: {
148
147
  roundness: DucElement["roundness"];
149
148
  opacity: DucElement["opacity"];
150
149
  locked: DucElement["locked"];
151
- scope: DucElement["scope"];
152
150
  index: DucElement["index"];
153
151
  width: DucElement["width"];
154
152
  height: DucElement["height"];
@@ -165,7 +163,7 @@ export declare const DEFAULT_IFRAME_LIKE_NO_STYLE: {
165
163
  };
166
164
  export declare const DEFAULT_LINEAR_ELEMENT_STROKE: ElementStroke;
167
165
  export declare const DEFAULT_FREEDRAW_ELEMENT: {
168
- size: RawValue;
166
+ size: number;
169
167
  thinning: DucFreeDrawElement["thinning"];
170
168
  smoothing: DucFreeDrawElement["smoothing"];
171
169
  streamline: DucFreeDrawElement["streamline"];
@@ -1,5 +1,6 @@
1
1
  import { ELEMENT_CONTENT_PREFERENCE, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN } from "../enums";
2
- import { MAX_ZOOM, MIN_ZOOM, NEUTRAL_SCOPE } from "../technical/scopes";
2
+ export const MIN_ZOOM = 1e-32;
3
+ export const MAX_ZOOM = 1e32;
3
4
  export const COLOR_PALETTE = {
4
5
  transparent: "transparent",
5
6
  black: "#1e1e1e",
@@ -32,11 +33,7 @@ export const IMAGE_MIME_TYPES = {
32
33
  avif: "image/avif",
33
34
  jfif: "image/jfif",
34
35
  };
35
- export const MIME_TYPES = Object.assign({ json: "application/json",
36
- // excalidraw data
37
- duc: "application/vnd.duc-cad", ducfig: "application/vnd.duc-config", excalidrawlib: "application/vnd.excalidrawlib+json",
38
- // image-encoded excalidraw data
39
- "excalidraw.svg": "image/svg+xml", "excalidraw.png": "image/png", binary: "application/octet-stream", pdf: "application/pdf", zip: "application/zip", xls: "application/vnd.ms-excel", xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", doc: "application/msword", docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", csv: "text/csv", markdown: "text/markdown", step: "model/step", stp: "application/step", stl: "model/stl" }, IMAGE_MIME_TYPES);
36
+ export const MIME_TYPES = Object.assign({ json: "application/json", duc: "application/vnd.duc", ducfig: "application/vnd.duc-config", excalidrawlib: "application/vnd.excalidrawlib+json", "excalidraw.svg": "image/svg+xml", "excalidraw.png": "image/png", binary: "application/octet-stream", pdf: "application/pdf", zip: "application/zip", xls: "application/vnd.ms-excel", xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", doc: "application/msword", docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", csv: "text/csv", markdown: "text/markdown", step: "model/step", stp: "application/step", stl: "model/stl" }, IMAGE_MIME_TYPES);
40
37
  export const EXPORT_IMAGE_TYPES = {
41
38
  png: "png",
42
39
  svg: "svg",
@@ -72,7 +69,6 @@ export const VERSIONS = {
72
69
  export const DEFAULT_ZOOM_STEP = 0.1;
73
70
  export const MIN_ZOOM_STEP = 0.0000001;
74
71
  export const MAX_ZOOM_STEP = 5;
75
- export { MAX_ZOOM, MIN_ZOOM };
76
72
  export const BOUND_TEXT_PADDING = 5;
77
73
  export const ARROW_LABEL_WIDTH_FRACTION = 0.7;
78
74
  export const ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO = 11;
@@ -194,7 +190,7 @@ export const DEFAULT_FRAME_STYLE = ({
194
190
  visible: true,
195
191
  opacity: 1,
196
192
  },
197
- width: { value: 2, scoped: 2 },
193
+ width: 2,
198
194
  style: {
199
195
  preference: STROKE_PREFERENCE.SOLID,
200
196
  join: STROKE_JOIN.MITER,
@@ -209,7 +205,7 @@ export const DEFAULT_FRAME_STYLE = ({
209
205
  opacity: 0.1,
210
206
  },
211
207
  }],
212
- roundness: { value: 0, scoped: 0 },
208
+ roundness: 0,
213
209
  radius: 8,
214
210
  nameOffsetY: 3,
215
211
  nameColorLightTheme: "#80808080",
@@ -225,7 +221,7 @@ export const DEFAULT_ELEMENT_PROPS = {
225
221
  visible: true,
226
222
  opacity: 1,
227
223
  },
228
- width: { value: 2, scoped: 2 },
224
+ width: 2,
229
225
  style: {
230
226
  preference: STROKE_PREFERENCE.SOLID,
231
227
  join: STROKE_JOIN.MITER,
@@ -242,13 +238,12 @@ export const DEFAULT_ELEMENT_PROPS = {
242
238
  },
243
239
  isVisible: true,
244
240
  isPlot: true,
245
- roundness: { value: 0, scoped: 0 },
241
+ roundness: 0,
246
242
  opacity: 1,
247
243
  locked: false,
248
- scope: NEUTRAL_SCOPE,
249
244
  index: null,
250
- width: { value: 0, scoped: 0 },
251
- height: { value: 0, scoped: 0 },
245
+ width: 0,
246
+ height: 0,
252
247
  angle: 0,
253
248
  groupIds: [],
254
249
  frameId: null,
@@ -341,7 +336,7 @@ export const PREDEFINED_HATCH_PATTERNS = {
341
336
  // visible: true,
342
337
  // opacity: 1,
343
338
  // },
344
- // width: { value: 1, scoped: 1 },
339
+ // width: 1,
345
340
  // style: {
346
341
  // preference: "solid",
347
342
  // scale: 1,
@@ -23,8 +23,10 @@ function getSvgPathFromStroke(points) {
23
23
  .replace(TO_FIXED_PRECISION, "$1");
24
24
  }
25
25
  function buildStrokeOptions(element) {
26
+ var _a, _b;
27
+ const size = (_b = (_a = element.size) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : element.size;
26
28
  return {
27
- size: element.size.scoped,
29
+ size,
28
30
  simulatePressure: element.simulatePressure,
29
31
  thinning: element.thinning,
30
32
  smoothing: element.smoothing,
@@ -42,9 +44,10 @@ const normalizeStrokePressure = (pressure) => {
42
44
  return Math.min(1, Math.max(0.05, pressure));
43
45
  };
44
46
  function buildInputPoints(element) {
47
+ const toNum = (v) => { var _a; return typeof v === "number" ? v : ((_a = v === null || v === void 0 ? void 0 : v.value) !== null && _a !== void 0 ? _a : 0); };
45
48
  return element.simulatePressure
46
- ? element.points.map(({ x, y }) => [x.scoped, y.scoped])
47
- : element.points.map(({ x, y }, i) => [x.scoped, y.scoped, normalizeStrokePressure(element.pressures[i])]);
49
+ ? element.points.map(({ x, y }) => [toNum(x), toNum(y)])
50
+ : element.points.map(({ x, y }, i) => [toNum(x), toNum(y), normalizeStrokePressure(element.pressures[i])]);
48
51
  }
49
52
  export function getFreeDrawSvgPath(element) {
50
53
  if (element.points.length === 0) {
@@ -3,14 +3,10 @@ export * from "./freedrawElement";
3
3
  export * from "./linearElement";
4
4
  export * from "./newElement";
5
5
  export * from "./textElement";
6
- import { Scope } from "../../types";
7
6
  import { _DucStackBase, DucElement, DucNonSelectionElement, DucTableElement, DucTextStyle, ElementConstructorOpts, NonDeleted } from "../../types/elements";
8
7
  import { GeometricPoint, TuplePoint } from "../../types/geometry.types";
9
8
  import { Mutable } from "../../types/utility.types";
10
- /**
11
- * Returns a default DucTextStyle object for the given scope.
12
- */
13
- export declare function getDefaultTextStyle(currentScope: Scope): DucTextStyle;
9
+ export declare function getDefaultTextStyle(): DucTextStyle;
14
10
  /**
15
11
  * Mutates element, bumping `version`, `versionNonce`, and `updated`.
16
12
  *
@@ -23,7 +19,7 @@ export declare const getDefaultStackProperties: () => _DucStackBase;
23
19
  * This does not include base element properties like x, y, width, etc.,
24
20
  * which are added during element creation.
25
21
  */
26
- export declare const getDefaultTableData: (currentScope: Scope) => {
22
+ export declare const getDefaultTableData: () => {
27
23
  fileId: DucTableElement["fileId"];
28
24
  gridConfig: DucTableElement["gridConfig"];
29
25
  };
@@ -5,14 +5,10 @@ export * from "./newElement";
5
5
  export * from "./textElement";
6
6
  import { getUpdatedTimestamp } from "..";
7
7
  import { LINE_SPACING_TYPE } from "../../enums";
8
- import { getPrecisionValueFromRaw } from "../../technical/scopes";
9
8
  import { isFreeDrawElement, isLinearElement } from "../../types/elements/typeChecks";
10
9
  import { DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN } from "../constants";
11
10
  import { randomInteger } from "../math/random";
12
- /**
13
- * Returns a default DucTextStyle object for the given scope.
14
- */
15
- export function getDefaultTextStyle(currentScope) {
11
+ export function getDefaultTextStyle() {
16
12
  return {
17
13
  isLtr: true,
18
14
  fontFamily: DEFAULT_FONT_FAMILY,
@@ -22,7 +18,7 @@ export function getDefaultTextStyle(currentScope) {
22
18
  lineHeight: 1.2,
23
19
  lineSpacing: { type: LINE_SPACING_TYPE.MULTIPLE, value: 1.2 },
24
20
  obliqueAngle: 0,
25
- fontSize: getPrecisionValueFromRaw(DEFAULT_FONT_SIZE, currentScope, currentScope),
21
+ fontSize: DEFAULT_FONT_SIZE,
26
22
  widthFactor: 1,
27
23
  isUpsideDown: false,
28
24
  isBackwards: false,
@@ -55,7 +51,7 @@ export const getDefaultStackProperties = () => {
55
51
  * This does not include base element properties like x, y, width, etc.,
56
52
  * which are added during element creation.
57
53
  */
58
- export const getDefaultTableData = (currentScope) => {
54
+ export const getDefaultTableData = () => {
59
55
  return {
60
56
  fileId: null,
61
57
  gridConfig: {
@@ -71,7 +67,6 @@ export const getBaseElementProps = (element) => {
71
67
  return {
72
68
  x: element.x,
73
69
  y: element.y,
74
- scope: element.scope,
75
70
  label: element.label,
76
71
  isVisible: element.isVisible,
77
72
  isPlot: element.isPlot,
@@ -114,7 +109,7 @@ export const isInvisiblySmallElement = (element) => {
114
109
  if (isLinearElement(element) || isFreeDrawElement(element)) {
115
110
  return element.points.length < 2;
116
111
  }
117
- return element.width.scoped === 0 && element.height.scoped === 0;
112
+ return element.width === 0 && element.height === 0;
118
113
  };
119
114
  /**
120
115
  * Sorts a list of DucElements by their z-index (lowest first).
@@ -1,4 +1,3 @@
1
- import type { PrecisionValue, RawValue, Scope } from "../../types";
2
1
  import type { DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, DucTextElementWithContainer, ElementsMap, NonDeleted } from "../../types/elements";
3
2
  import { Bounds, GeometricPoint } from "../../types/geometry.types";
4
3
  import type { ValueOf } from "../../types/utility.types";
@@ -15,7 +14,7 @@ export type HandleInfo = {
15
14
  * Merges overlapping points using the line-based system
16
15
  * Returns updated points and lines arrays
17
16
  */
18
- export declare const mergeOverlappingPoints: (points: DucPoint[], lines: DucLine[], threshold?: RawValue) => {
17
+ export declare const mergeOverlappingPoints: (points: DucPoint[], lines: DucLine[], threshold?: number) => {
19
18
  points: DucPoint[];
20
19
  lines: DucLine[];
21
20
  };
@@ -27,23 +26,22 @@ export declare const mergeOverlappingPoints: (points: DucPoint[], lines: DucLine
27
26
  export declare const getNormalizedPoints: (element: DucLinearElement | {
28
27
  points: DucPoint[];
29
28
  lines: DucLine[];
30
- x: PrecisionValue;
31
- y: PrecisionValue;
32
- scope: Scope;
33
- }, currentScope: Scope) => {
29
+ x: number;
30
+ y: number;
31
+ }) => {
34
32
  points: DucPoint[];
35
33
  lines: DucLine[];
36
- x: PrecisionValue;
37
- y: PrecisionValue;
34
+ x: number;
35
+ y: number;
38
36
  };
39
37
  /** scene coords */
40
- export declare const getPointsGlobalCoordinates: (element: DucLinearLikeElement, elementsMap: ElementsMap, currentScope: Scope) => DucPoint[];
38
+ export declare const getPointsGlobalCoordinates: (element: DucLinearLikeElement, elementsMap: ElementsMap) => DucPoint[];
41
39
  /** scene coords */
42
- export declare const getPointGlobalCoordinates: (element: DucLinearLikeElement, point: GeometricPoint, elementsMap: ElementsMap, currentScope: Scope) => GeometricPoint;
43
- export declare const getBoundTextElementPosition: (element: DucLinearLikeElement, boundTextElement: DucTextElementWithContainer, elementsMap: ElementsMap, currentScope: Scope) => GeometricPoint | null;
44
- export declare const getLinearElementAbsoluteCoords: (element: DucLinearElement, elementsMap: ElementsMap, includeBoundText: boolean | undefined, currentScope: Scope, returnUnrotatedBoundsOnly?: boolean) => ElementAbsoluteCoords;
45
- export declare const getMinMaxXYWithBoundText: (element: DucLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: DucTextElementWithContainer, currentScope: Scope) => ElementAbsoluteCoords;
46
- export declare const getSegmentMidPoint: (element: NonDeleted<DucLinearLikeElement>, startPoint: GeometricPoint, endPoint: GeometricPoint, endPointIndex: number, elementsMap: ElementsMap, currentScope: Scope) => GeometricPoint;
40
+ export declare const getPointGlobalCoordinates: (element: DucLinearLikeElement, point: GeometricPoint, elementsMap: ElementsMap) => GeometricPoint;
41
+ export declare const getBoundTextElementPosition: (element: DucLinearLikeElement, boundTextElement: DucTextElementWithContainer, elementsMap: ElementsMap) => GeometricPoint | null;
42
+ export declare const getLinearElementAbsoluteCoords: (element: DucLinearElement, elementsMap: ElementsMap, includeBoundText?: boolean, returnUnrotatedBoundsOnly?: boolean) => ElementAbsoluteCoords;
43
+ export declare const getMinMaxXYWithBoundText: (element: DucLinearElement, elementsMap: ElementsMap, elementBounds: Bounds, boundTextElement: DucTextElementWithContainer) => ElementAbsoluteCoords;
44
+ export declare const getSegmentMidPoint: (element: NonDeleted<DucLinearLikeElement>, startPoint: GeometricPoint, endPoint: GeometricPoint, endPointIndex: number, elementsMap: ElementsMap) => GeometricPoint;
47
45
  /**
48
46
  * Validates if the given line indices form a closed path in the element
49
47
  * @param element The linear element containing the points and lines