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
@@ -0,0 +1,119 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import readline from "readline";
11
+ import { renderModelViewThumbnail, } from "./render";
12
+ import { getSharedBrowserRunner, } from "./browserRunner";
13
+ /**
14
+ * Runs a persistent thumbnail rendering server over stdin/stdout using JSON lines.
15
+ * Designed for seamless integration with Rust subprocesses (e.g. ducpdf, ducrs).
16
+ */
17
+ export function runThumbnailWorkerServer() {
18
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
19
+ var _a, _b, _c, _d;
20
+ const inputStream = (_a = options.stdin) !== null && _a !== void 0 ? _a : process.stdin;
21
+ const outputStream = (_b = options.stdout) !== null && _b !== void 0 ? _b : process.stdout;
22
+ const runner = (_c = options.runner) !== null && _c !== void 0 ? _c : getSharedBrowserRunner({
23
+ executablePath: options.browserExecutablePath,
24
+ useSoftwareRenderer: (_d = options.useSoftwareRenderer) !== null && _d !== void 0 ? _d : true,
25
+ });
26
+ // Pre-warm the headless browser
27
+ try {
28
+ yield runner.start();
29
+ }
30
+ catch (err) {
31
+ // Stderr logging for diagnostics without corrupting stdout JSON protocol
32
+ console.error("[ThumbnailWorker] Warning during pre-warm:", err);
33
+ }
34
+ const rl = readline.createInterface({
35
+ input: inputStream,
36
+ terminal: false,
37
+ });
38
+ const sendResponse = (response) => {
39
+ outputStream.write(`${JSON.stringify(response)}\n`);
40
+ };
41
+ rl.on("line", (line) => __awaiter(this, void 0, void 0, function* () {
42
+ const trimmed = line.trim();
43
+ if (!trimmed)
44
+ return;
45
+ let req;
46
+ try {
47
+ req = JSON.parse(trimmed);
48
+ }
49
+ catch (err) {
50
+ sendResponse({
51
+ id: "unknown",
52
+ ok: false,
53
+ error: `Invalid JSON request: ${err instanceof Error ? err.message : String(err)}`,
54
+ });
55
+ return;
56
+ }
57
+ if (req.action === "ping") {
58
+ sendResponse({ id: req.id, ok: true });
59
+ return;
60
+ }
61
+ if (req.action === "shutdown") {
62
+ try {
63
+ yield runner.stop();
64
+ }
65
+ catch (_a) {
66
+ // Best-effort
67
+ }
68
+ sendResponse({ id: req.id, ok: true });
69
+ process.exit(0);
70
+ return;
71
+ }
72
+ if (req.action === "render") {
73
+ try {
74
+ let input = req.input;
75
+ if (!input && req.element) {
76
+ input = {
77
+ modelType: req.element.modelType,
78
+ viewerState: req.element.viewerState,
79
+ viewConfig: req.viewConfig,
80
+ };
81
+ }
82
+ if (!input) {
83
+ sendResponse({
84
+ id: req.id,
85
+ ok: false,
86
+ error: "Missing input or element in render request.",
87
+ });
88
+ return;
89
+ }
90
+ const renderRes = yield renderModelViewThumbnail(input, Object.assign(Object.assign({}, options), { runner }));
91
+ sendResponse({
92
+ id: req.id,
93
+ ok: true,
94
+ result: {
95
+ base64: renderRes.base64,
96
+ format: renderRes.format,
97
+ width: renderRes.width,
98
+ height: renderRes.height,
99
+ renderTimeMs: renderRes.renderTimeMs,
100
+ },
101
+ });
102
+ }
103
+ catch (err) {
104
+ sendResponse({
105
+ id: req.id,
106
+ ok: false,
107
+ error: err instanceof Error ? err.message : String(err),
108
+ });
109
+ }
110
+ return;
111
+ }
112
+ sendResponse({
113
+ id: req.id,
114
+ ok: false,
115
+ error: `Unknown action: ${req.action}`,
116
+ });
117
+ }));
118
+ });
119
+ }
@@ -7,6 +7,6 @@
7
7
  export declare function transformFromRust(data: any): any;
8
8
  /**
9
9
  * Pre-serialize transformation: re-wrap stack element fields
10
- * and flatten PrecisionValue objects to plain numbers for Rust.
10
+ * and unwrap numeric values to plain numbers for Rust.
11
11
  */
12
12
  export declare function transformToRust(data: any): any;
package/dist/transform.js CHANGED
@@ -69,14 +69,14 @@ export function transformFromRust(data) {
69
69
  }
70
70
  /**
71
71
  * Pre-serialize transformation: re-wrap stack element fields
72
- * and flatten PrecisionValue objects to plain numbers for Rust.
72
+ * and unwrap numeric values to plain numbers for Rust.
73
73
  */
74
74
  export function transformToRust(data) {
75
75
  if (!data)
76
76
  return data;
77
77
  const result = Object.assign({}, data);
78
78
  if (result.elements) {
79
- result.elements = result.elements.map((el) => coerceElementIntegerFields(flattenPrecisionValues(fixElementToRust(el))));
79
+ result.elements = result.elements.map((el) => coerceElementIntegerFields(unwrapNumericValues(fixElementToRust(el))));
80
80
  }
81
81
  if (result.localState) {
82
82
  result.localState = normalizeLocalStateForRust(result.localState);
@@ -106,7 +106,7 @@ export function transformToRust(data) {
106
106
  if (l.overrides) {
107
107
  l.overrides = fixLayerOverridesHatch(l.overrides, false);
108
108
  }
109
- return flattenPrecisionValues(l);
109
+ return unwrapNumericValues(l);
110
110
  });
111
111
  }
112
112
  if (result.blockInstances) {
@@ -115,7 +115,7 @@ export function transformToRust(data) {
115
115
  if (b.elementOverrides && !Array.isArray(b.elementOverrides) && typeof b.elementOverrides === "object") {
116
116
  b.elementOverrides = Object.entries(b.elementOverrides).map(([key, value]) => ({ key, value: String(value) }));
117
117
  }
118
- return flattenPrecisionValues(b);
118
+ return unwrapNumericValues(b);
119
119
  });
120
120
  }
121
121
  if (result.blocks) {
@@ -419,17 +419,16 @@ function fixElementToRust(el) {
419
419
  } });
420
420
  }
421
421
  /**
422
- * Recursively convert PrecisionValue objects ({value, scoped}) to plain
423
- * numbers (extracting `.value` — the raw/unscoped value) so Rust's serde
424
- * can deserialize them as f64.
422
+ * Recursively unwrap any wrapped numeric values ({value: number}) to plain
423
+ * numbers so Rust's serde can deserialize them as f64.
425
424
  */
426
- function flattenPrecisionValues(obj) {
425
+ function unwrapNumericValues(obj) {
427
426
  if (obj === null || obj === undefined)
428
427
  return obj;
429
- if (isPrecisionValueLike(obj))
428
+ if (isNumericWrapper(obj))
430
429
  return obj.value;
431
430
  if (Array.isArray(obj))
432
- return obj.map(flattenPrecisionValues);
431
+ return obj.map(unwrapNumericValues);
433
432
  if (ArrayBuffer.isView(obj) || obj instanceof ArrayBuffer) {
434
433
  return obj;
435
434
  }
@@ -438,24 +437,23 @@ function flattenPrecisionValues(obj) {
438
437
  for (const key in obj) {
439
438
  if (!Object.prototype.hasOwnProperty.call(obj, key))
440
439
  continue;
441
- out[key] = flattenPrecisionValues(obj[key]);
440
+ out[key] = unwrapNumericValues(obj[key]);
442
441
  }
443
442
  return out;
444
443
  }
445
444
  return obj;
446
445
  }
447
- function isPrecisionValueLike(v) {
446
+ function isNumericWrapper(v) {
448
447
  return (v !== null &&
449
448
  typeof v === "object" &&
450
449
  !Array.isArray(v) &&
451
450
  typeof v.value === "number" &&
452
- typeof v.scoped === "number" &&
453
- Object.keys(v).length === 2);
451
+ Object.keys(v).every((k) => k === "value" || k === "scaled"));
454
452
  }
455
- function toNumberFromPrecisionLike(value, fallback) {
456
- const flattened = flattenPrecisionValues(value);
457
- if (typeof flattened === "number" && Number.isFinite(flattened)) {
458
- return flattened;
453
+ function toNumberFromNumeric(value, fallback) {
454
+ const unwrapped = unwrapNumericValues(value);
455
+ if (typeof unwrapped === "number" && Number.isFinite(unwrapped)) {
456
+ return unwrapped;
459
457
  }
460
458
  return fallback;
461
459
  }
@@ -472,14 +470,14 @@ function coerceElementIntegerFields(el) {
472
470
  function normalizeLocalStateForRust(localState) {
473
471
  if (!localState || typeof localState !== "object")
474
472
  return localState;
475
- return Object.assign(Object.assign({}, localState), { scrollX: toNumberFromPrecisionLike(localState.scrollX, 0), scrollY: toNumberFromPrecisionLike(localState.scrollY, 0), zoom: localState.zoom && typeof localState.zoom === "object"
476
- ? toNumberFromPrecisionLike(localState.zoom.value, 1)
477
- : toNumberFromPrecisionLike(localState.zoom, 1), currentItemStroke: flattenPrecisionValues(localState.currentItemStroke), currentItemBackground: flattenPrecisionValues(localState.currentItemBackground), currentItemFontSize: toNumberFromPrecisionLike(localState.currentItemFontSize, 16), currentItemRoundness: toNumberFromPrecisionLike(localState.currentItemRoundness, 0), currentItemTextAlign: toInteger(localState.currentItemTextAlign, 10), decimalPlaces: toInteger(localState.decimalPlaces, 2) });
473
+ return Object.assign(Object.assign({}, localState), { scrollX: toNumberFromNumeric(localState.scrollX, 0), scrollY: toNumberFromNumeric(localState.scrollY, 0), zoom: localState.zoom && typeof localState.zoom === "object"
474
+ ? toNumberFromNumeric(localState.zoom.value, 1)
475
+ : toNumberFromNumeric(localState.zoom, 1), currentItemStroke: unwrapNumericValues(localState.currentItemStroke), currentItemBackground: unwrapNumericValues(localState.currentItemBackground), currentItemFontSize: toNumberFromNumeric(localState.currentItemFontSize, 16), currentItemRoundness: toNumberFromNumeric(localState.currentItemRoundness, 0), currentItemTextAlign: toInteger(localState.currentItemTextAlign, 10), decimalPlaces: toInteger(localState.decimalPlaces, 2) });
478
476
  }
479
477
  function normalizeGlobalStateForRust(globalState) {
480
478
  if (!globalState || typeof globalState !== "object")
481
479
  return globalState;
482
- return Object.assign(Object.assign({}, globalState), { scopeExponentThreshold: toInteger(globalState.scopeExponentThreshold, 4) });
480
+ return Object.assign({}, globalState);
483
481
  }
484
482
  function easingFnToName(fn) {
485
483
  var _a;
@@ -1,5 +1,4 @@
1
1
  export * from "./typeChecks";
2
- import { PrecisionValue, Scope } from "..";
3
2
  import { BEZIER_MIRRORING, BLENDING, BOOLEAN_OPERATION, ELEMENT_CONTENT_PREFERENCE, HATCH_STYLE, IMAGE_STATUS, LINE_HEAD, LINE_SPACING_TYPE, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN } from "../../enums";
4
3
  import { FONT_FAMILY, FREEDRAW_EASINGS } from "../../utils/constants";
5
4
  import { GeometricPoint, Percentage, Radian, ScaleFactor } from "../geometry.types";
@@ -8,7 +7,7 @@ import { MakeBrand, MarkNonNullable, MarkOptional, Merge, ValueOf } from "../uti
8
7
  * Base styles that all elements share
9
8
  */
10
9
  export type _DucElementStylesBase = {
11
- roundness: PrecisionValue;
10
+ roundness: number;
12
11
  blending?: Blending;
13
12
  /** @deprecated
14
13
  * Use stroke.content.src instead
@@ -27,17 +26,12 @@ export type _DucElementStylesBase = {
27
26
  */
28
27
  export type _DucElementBase = Readonly<_DucElementStylesBase & {
29
28
  id: string;
30
- x: PrecisionValue;
31
- y: PrecisionValue;
32
- /**
33
- * The scope where the element is currently
34
- * mm, cm, m, in, ft, yd, mi, etc...
35
- */
36
- scope: Scope;
29
+ x: number;
30
+ y: number;
37
31
  label: string;
38
32
  isVisible: boolean;
39
- width: PrecisionValue;
40
- height: PrecisionValue;
33
+ width: number;
34
+ height: number;
41
35
  angle: Radian;
42
36
  /** Random integer used to seed shape generation
43
37
  doesn't differ across renders. */
@@ -162,7 +156,7 @@ export type DucElementSelectableField = keyof DucElement | keyof Extract<DucElem
162
156
  }> | keyof Extract<DucElement, {
163
157
  type: "embeddable";
164
158
  }>;
165
- export declare const DUC_ELEMENT_SELECTABLE_FIELDS: readonly ["id", "type", "label", "x", "y", "width", "height", "angle", "opacity", "isDeleted", "isVisible", "groupIds", "frameId", "scope", "layerId", "zIndex", "description", "customData", "roundness", "blending", "background", "stroke", "boundElements", "link", "locked", "regionIds", "blockIds", "instanceId", "index", "updated", "version", "versionNonce", "seed", "modelType", "fileIds", "code", "thumbnail", "viewerState", "text", "autoResize", "containerId", "originalText", "isLtr", "fontFamily", "bigFontFamily", "fontSize", "textAlign", "verticalAlign", "lineHeight", "lineSpacing", "obliqueAngle", "widthFactor", "isUpsideDown", "isBackwards", "points", "fileId", "status", "scaleFlip", "crop", "filter", "elbowed", "wipeoutBelow", "clip", "labelVisible", "layout", "gridConfig", "referencedFileIds", "sides", "ratio", "startAngle", "endAngle", "showAuxCrosshair", "size", "thinning", "smoothing", "streamline", "easing", "start", "end", "pressures", "simulatePressure", "lastCommittedPoint", "lines", "pathOverrides", "startBinding", "endBinding", "svgPath", "isPlot", "isCollapsed"];
159
+ export declare const DUC_ELEMENT_SELECTABLE_FIELDS: readonly ["id", "type", "label", "x", "y", "width", "height", "angle", "opacity", "isDeleted", "isVisible", "groupIds", "frameId", "layerId", "zIndex", "description", "customData", "roundness", "blending", "background", "stroke", "boundElements", "link", "locked", "regionIds", "blockIds", "instanceId", "index", "updated", "version", "versionNonce", "seed", "modelType", "fileIds", "code", "thumbnail", "viewerState", "text", "autoResize", "containerId", "originalText", "isLtr", "fontFamily", "bigFontFamily", "fontSize", "textAlign", "verticalAlign", "lineHeight", "lineSpacing", "obliqueAngle", "widthFactor", "isUpsideDown", "isBackwards", "points", "fileId", "status", "scaleFlip", "crop", "filter", "elbowed", "wipeoutBelow", "clip", "labelVisible", "layout", "gridConfig", "referencedFileIds", "sides", "ratio", "startAngle", "endAngle", "showAuxCrosshair", "size", "thinning", "smoothing", "streamline", "easing", "start", "end", "pressures", "simulatePressure", "lastCommittedPoint", "lines", "pathOverrides", "startBinding", "endBinding", "svgPath", "isPlot", "isCollapsed"];
166
160
  export declare const DUC_ELEMENT_COMMUNICATION_DENY_FIELDS: readonly ["seed", "versionNonce", "thumbnail", "svgPath", "originalText"];
167
161
  export type DucElementCommunicationDenyField = typeof DUC_ELEMENT_COMMUNICATION_DENY_FIELDS[number];
168
162
  export declare const DUC_ELEMENT_COMMUNICATION_DENY_FIELD_SET: ReadonlySet<string>;
@@ -182,7 +176,7 @@ export type DucStackLikeElement = DucPlotElement | DucFrameElement;
182
176
  export type DucLinearLikeElement = DucLinearElement | DucArrowElement;
183
177
  export type DucFrameLikeElement = DucPlotElement | DucFrameElement;
184
178
  export type DucIframeLikeElement = DucEmbeddableElement | DucTableElement | DucDocElement;
185
- export type ElementConstructorOpts = MarkOptional<Omit<DucGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "blockIds" | "instanceId" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "background" | "stroke" | "roundness" | "locked" | "opacity" | "customData" | "isVisible" | "description" | "scope" | "blending" | "isPlot" | "regionIds" | "layerId">;
179
+ export type ElementConstructorOpts = MarkOptional<Omit<DucGenericElement, "id" | "type" | "isDeleted" | "updated">, "width" | "height" | "angle" | "groupIds" | "blockIds" | "instanceId" | "frameId" | "index" | "boundElements" | "seed" | "version" | "versionNonce" | "link" | "background" | "stroke" | "roundness" | "locked" | "opacity" | "customData" | "isVisible" | "description" | "blending" | "isPlot" | "regionIds" | "layerId">;
186
180
  export type ElementUpdate<TElement extends DucElement> = Omit<Partial<TElement>, "id" | "version" | "versionNonce" | "updated">;
187
181
  export type DucElementType = DucElement["type"];
188
182
  export type DucCommonStyle = {
@@ -223,9 +217,9 @@ export type HatchPatternLine = {
223
217
  /** Line origin point */
224
218
  origin: DucPoint;
225
219
  /** Offset between parallel lines [x, y] */
226
- offset: [PrecisionValue, PrecisionValue];
220
+ offset: [number, number];
227
221
  /** Dash pattern (empty array = solid line) */
228
- dashPattern: PrecisionValue[];
222
+ dashPattern: number[];
229
223
  };
230
224
  /**
231
225
  * Custom hatch pattern definition
@@ -316,7 +310,7 @@ export type ElementContentBase = {
316
310
  };
317
311
  export type ElementStroke = {
318
312
  content: ElementContentBase;
319
- width: PrecisionValue;
313
+ width: number;
320
314
  style: StrokeStyle;
321
315
  placement: StrokePlacement;
322
316
  strokeSides?: StrokeSides;
@@ -447,7 +441,7 @@ export type DucTextStyle = {
447
441
  * The numerical value for the line spacing.
448
442
  * Its interpretation depends on the `type` property.
449
443
  */
450
- value: PrecisionValue | ScaleFactor;
444
+ value: number | ScaleFactor;
451
445
  /**
452
446
  * Determines how the line spacing factor is applied.
453
447
  * - `at_least`: The line spacing is the larger of the `value` or the tallest character's natural height.
@@ -470,7 +464,7 @@ export type DucTextStyle = {
470
464
  * Text height in drawing units (primary size parameter)
471
465
  * This determines the height of capital letters
472
466
  */
473
- fontSize: PrecisionValue;
467
+ fontSize: number;
474
468
  /**
475
469
  * Character width as a ratio of text height
476
470
  * Controls horizontal spacing and character proportions
@@ -522,7 +516,7 @@ export type DucPointBinding = {
522
516
  /**
523
517
  * The gap distance between the bound element and the binding element.
524
518
  */
525
- gap: PrecisionValue;
519
+ gap: number;
526
520
  /**
527
521
  * Represents a fixed point inside the bound element, defined as a normalized coordinate.
528
522
  * This value is an array [x, y], where:
@@ -561,8 +555,8 @@ export type DucHead = {
561
555
  size: number;
562
556
  };
563
557
  export interface DucPointPosition {
564
- x: PrecisionValue;
565
- y: PrecisionValue;
558
+ x: number;
559
+ y: number;
566
560
  }
567
561
  export type BezierMirroring = ValueOf<typeof BEZIER_MIRRORING>;
568
562
  export type DucPoint = DucPointPosition & {
@@ -620,7 +614,7 @@ export type DucFreeDrawEnds = {
620
614
  export type DucFreeDrawElement = _DucElementBase & {
621
615
  type: "freedraw";
622
616
  points: readonly DucPoint[];
623
- size: PrecisionValue;
617
+ size: number;
624
618
  thinning: Percentage;
625
619
  smoothing: Percentage;
626
620
  streamline: Percentage;
@@ -635,8 +629,8 @@ export type DucFreeDrawElement = _DucElementBase & {
635
629
  export type DucBlockDuplicationArray = {
636
630
  rows: number;
637
631
  cols: number;
638
- rowSpacing: PrecisionValue;
639
- colSpacing: PrecisionValue;
632
+ rowSpacing: number;
633
+ colSpacing: number;
640
634
  };
641
635
  /**
642
636
  * Indicates the source drawing of a block.
@@ -763,10 +757,10 @@ export type DucLayer = _DucStackBase & {
763
757
  export type PlotLayout = {
764
758
  /** Margins inset from the edge of the paper. */
765
759
  margins: {
766
- top: PrecisionValue;
767
- right: PrecisionValue;
768
- bottom: PrecisionValue;
769
- left: PrecisionValue;
760
+ top: number;
761
+ right: number;
762
+ bottom: number;
763
+ left: number;
770
764
  };
771
765
  };
772
766
  export type DucPlotStyle = {};
@@ -13,7 +13,6 @@ export const DUC_ELEMENT_SELECTABLE_FIELDS = [
13
13
  "isVisible",
14
14
  "groupIds",
15
15
  "frameId",
16
- "scope",
17
16
  "layerId",
18
17
  "zIndex",
19
18
  "description",
@@ -1,5 +1,5 @@
1
1
  import { AXIS } from "../enums";
2
- import { ScopedValue, ValueOf } from ".";
2
+ import { ValueOf } from ".";
3
3
  /**
4
4
  * Axis such as X, Y, Z
5
5
  */
@@ -8,10 +8,10 @@ export type Axis = ValueOf<typeof AXIS>;
8
8
  * x and y position of top left corner, x and y position of bottom right corner
9
9
  */
10
10
  export type Bounds = readonly [
11
- minX: ScopedValue,
12
- minY: ScopedValue,
13
- maxX: ScopedValue,
14
- maxY: ScopedValue
11
+ minX: number,
12
+ minY: number,
13
+ maxX: number,
14
+ maxY: number
15
15
  ];
16
16
  /**
17
17
  * Scale factor is a multiplier to a given value
@@ -2,9 +2,7 @@ export * from "./charter.types";
2
2
  export * from "./elements";
3
3
  export * from "./geometry.types";
4
4
  export * from "./issues.types";
5
- export * from "./typeChecks";
6
5
  export * from "./utility.types";
7
- import { SupportedMeasures } from "../technical/scopes";
8
6
  import { DucCharter } from "./charter.types";
9
7
  import { DucBindableElement, DucBlock, DucBlockCollection, DucBlockInstance, DucElement, DucElementType, DucGroup, DucIframeLikeElement, DucLayer, DucLinearElement, DucRegion, DucTextElement, ElementBackground, ElementStroke, ExternalFileId, FontFamilyValues, LineHead, NonDeleted, TextAlign } from "./elements";
10
8
  import { Percentage } from "./geometry.types";
@@ -60,7 +58,12 @@ export interface Actor {
60
58
  identifier: string;
61
59
  name?: string;
62
60
  }
63
- export type Scope = SupportedMeasures;
61
+ export type ExternalFileLocatorKind = "relative" | "absolute";
62
+ export type ExternalFileLocator = {
63
+ kind: ExternalFileLocatorKind;
64
+ path: string;
65
+ originalPath?: string;
66
+ };
64
67
  export type ExternalFileRevisionMeta = {
65
68
  id: string;
66
69
  sizeBytes: number;
@@ -78,6 +81,8 @@ export type ExternalFileRevisionMeta = {
78
81
  * the scene. Used to determine whether to delete unused files from storage.
79
82
  */
80
83
  lastRetrieved?: number;
84
+ /** Durable external-file locator on disk or host device. */
85
+ locator?: ExternalFileLocator;
81
86
  };
82
87
  /**
83
88
  * Minimal resolved file data for rendering — just the bytes and their MIME type.
@@ -121,24 +126,10 @@ export type DucGlobalState = {
121
126
  * The background color of the drawing
122
127
  */
123
128
  viewBackgroundColor: string;
124
- /**
125
- * The master unit system for the entire drawing, used for block/file insertion scaling.
126
- */
127
- mainScope: Scope;
128
- /**
129
- * Exponent threshold for determining when to change measurement scope (up or down).
130
- * This value defines a +/- tolerance range around the exponent of the current scope.
131
- */
132
- scopeExponentThreshold: number;
133
129
  };
134
130
  export type DucLocalState = {
135
- /**
136
- * The current scope of the design
137
- * mm, cm, m, in, ft, yd, mi, etc...
138
- */
139
- scope: Scope;
140
- scrollX: PrecisionValue;
141
- scrollY: PrecisionValue;
131
+ scrollX: number;
132
+ scrollY: number;
142
133
  zoom: Zoom;
143
134
  isBindingEnabled: boolean;
144
135
  currentItemStroke: ElementStroke;
@@ -177,54 +168,17 @@ export type DucLocalState = {
177
168
  export type NormalizedZoomValue = number & {
178
169
  _brand: "normalizedZoom";
179
170
  };
180
- /**
181
- * A value that accurate/relative to the current scope
182
- */
183
- export type ScopedValue = number & {
184
- _brand: "scopedValue";
185
- };
186
- /**
187
- * A value that represent the raw value of the element on its scope
188
- */
189
- export type RawValue = number & {
190
- _brand: "rawValue";
191
- };
192
- /**
193
- * A value that accurate to the current scope particularly for zoom, it works in reverse for zoom
194
- */
195
- export type ScopedZoomValue = number & {
196
- _brand: "scopedZoomValue";
197
- };
198
- /**
199
- * A value that represent the scaled zoom value relative to a scale bar
200
- */
201
- export type ScaledZoom = number & {
202
- _brand: "scaledZoom";
203
- };
171
+ export type ScaledZoom = number;
204
172
  export type Zoom = Readonly<{
205
173
  /**
206
174
  * The raw and normalized value of the zoom
207
175
  */
208
176
  value: NormalizedZoomValue;
209
177
  /**
210
- * The value of the zoom relative to the current scope
178
+ * The value of the zoom adapted to the UI scale bar
211
179
  */
212
- scoped: ScopedZoomValue;
213
- /**
214
- * The value of the zoom adapted to the UI scale bar, for real life measurements
215
- */
216
- scaled: ScaledZoom;
180
+ scaled?: ScaledZoom;
217
181
  }>;
218
- export type PrecisionValue = {
219
- /**
220
- * The raw value of the scroll
221
- */
222
- value: RawValue;
223
- /**
224
- * The value of the scroll relative to the current scope
225
- */
226
- scoped: ScopedValue;
227
- };
228
182
  export type PointerCoords = Readonly<{
229
183
  x: number;
230
184
  y: number;
@@ -2,5 +2,4 @@ export * from "./charter.types";
2
2
  export * from "./elements";
3
3
  export * from "./geometry.types";
4
4
  export * from "./issues.types";
5
- export * from "./typeChecks";
6
5
  export * from "./utility.types";
@@ -1,4 +1,4 @@
1
- import { Actor, Scope, Viewer3DState } from ".";
1
+ import { Actor, Viewer3DState } from ".";
2
2
  export type DucIssueStatus = "open" | "closed" | "dismissed";
3
3
  /** A single message in an issue thread. */
4
4
  export interface DucIssueMessage {
@@ -18,7 +18,6 @@ export type DucIssueAnchor = {
18
18
  /** Canvas location in drawing units. */
19
19
  x: number;
20
20
  y: number;
21
- scope?: Scope;
22
21
  } | {
23
22
  type: "element";
24
23
  elementId: string;
@@ -1,25 +1,24 @@
1
- import { Scope, ScopedValue } from "../types";
2
1
  import { DucElement, DucFreeDrawElement, DucLine, DucLinearElement, DucPoint, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap } from "../types/elements";
3
2
  import { Bounds, GeometricPoint } from "../types/geometry.types";
4
- export type SV = ScopedValue;
3
+ export type SV = number;
5
4
  /**
6
5
  * Common bounds calculation interface
7
6
  */
8
7
  export interface BoundsResult {
9
- minX: ScopedValue;
10
- minY: ScopedValue;
11
- maxX: ScopedValue;
12
- maxY: ScopedValue;
8
+ minX: number;
9
+ minY: number;
10
+ maxX: number;
11
+ maxY: number;
13
12
  }
14
13
  /**
15
14
  * Extended bounds calculation interface with center coordinates
16
15
  */
17
16
  export interface ExtendedBoundsResult extends BoundsResult {
18
- cx: ScopedValue;
19
- cy: ScopedValue;
17
+ cx: number;
18
+ cy: number;
20
19
  }
21
20
  export type ElementAbsoluteCoords = [SV, SV, SV, SV, SV, SV];
22
- export declare const getElementAbsoluteCoords: (element: DucElement, elementsMap: ElementsMap, currentScope: Scope, includeBoundText?: boolean, returnUnrotatedBoundsOnly?: boolean) => ElementAbsoluteCoords;
21
+ export declare const getElementAbsoluteCoords: (element: DucElement, elementsMap: ElementsMap, includeBoundText?: boolean, returnUnrotatedBoundsOnly?: boolean) => ElementAbsoluteCoords;
23
22
  /**
24
23
  * Calculates bounds from a list of points (basic implementation)
25
24
  */
@@ -36,7 +35,7 @@ export declare const processBezierCurveBounds: (points: readonly DucPoint[], lin
36
35
  * Processes Bezier curves with rotation and absolute positioning
37
36
  * Used for linear elements that need to account for rotation and absolute coordinates
38
37
  */
39
- export declare const processRotatedAbsoluteBezierBounds: (points: readonly DucPoint[], lines: readonly DucLine[], elementX: ScopedValue, elementY: ScopedValue, centerX: ScopedValue, centerY: ScopedValue, angle: number) => {
38
+ export declare const processRotatedAbsoluteBezierBounds: (points: readonly DucPoint[], lines: readonly DucLine[], elementX: number, elementY: number, centerX: number, centerY: number, angle: number) => {
40
39
  minX: number;
41
40
  minY: number;
42
41
  maxX: number;
@@ -71,4 +70,4 @@ export declare const getBoundsFromPoints: (points: GeometricPoint[]) => Bounds;
71
70
  export declare const getFreeDrawElementAbsoluteCoords: (element: DucFreeDrawElement) => ElementAbsoluteCoords;
72
71
  export declare const getBoundTextElementId: (container: DucElement | null) => string | null;
73
72
  export declare const getBoundTextElement: (element: DucElement | null, elementsMap: ElementsMap) => DucTextElementWithContainer | null;
74
- export declare const getResizedElementAbsoluteCoords: (element: DucElement, nextWidth: ScopedValue, nextHeight: ScopedValue, normalizePoints: boolean, currentScope: Scope) => Bounds;
73
+ export declare const getResizedElementAbsoluteCoords: (element: DucElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => Bounds;