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.
- package/dist/duc_locator_wasm.d.ts +48 -0
- package/dist/duc_locator_wasm.js +296 -0
- package/dist/duc_locator_wasm_bg.wasm +0 -0
- package/dist/duc_locator_wasm_bg.wasm.d.ts +13 -0
- package/dist/ducjs_wasi.wasm +0 -0
- package/dist/ducjs_wasm.d.ts +14 -2
- package/dist/ducjs_wasm.js +96 -8
- package/dist/ducjs_wasm_bg.wasm +0 -0
- package/dist/ducjs_wasm_bg.wasm.d.ts +6 -2
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/locator-runtime.d.ts +4 -0
- package/dist/locator-runtime.js +7 -0
- package/dist/restore/index.d.ts +1 -0
- package/dist/restore/index.js +1 -0
- package/dist/restore/restoreDataState.d.ts +13 -24
- package/dist/restore/restoreDataState.js +49 -83
- package/dist/restore/restoreElements.d.ts +10 -15
- package/dist/restore/restoreElements.js +128 -125
- package/dist/restore/updateModelCode.d.ts +11 -0
- package/dist/restore/updateModelCode.js +63 -0
- package/dist/thumbnails/bounds.d.ts +21 -0
- package/dist/thumbnails/bounds.js +84 -0
- package/dist/thumbnails/browserRunner.d.ts +60 -0
- package/dist/thumbnails/browserRunner.js +446 -0
- package/dist/thumbnails/cameraPresets.d.ts +47 -0
- package/dist/thumbnails/cameraPresets.js +222 -0
- package/dist/thumbnails/cli.d.ts +2 -0
- package/dist/thumbnails/cli.js +102 -0
- package/dist/thumbnails/index.d.ts +11 -0
- package/dist/thumbnails/index.js +11 -0
- package/dist/thumbnails/lib/clientBundle.min.js +10427 -0
- package/dist/thumbnails/lib/clientEntry.d.ts +3 -0
- package/dist/thumbnails/lib/clientEntry.js +8 -0
- package/dist/thumbnails/lib/clippingUtils.d.ts +10 -0
- package/dist/thumbnails/lib/clippingUtils.js +3 -0
- package/dist/thumbnails/lib/defaultModelColor.d.ts +3 -0
- package/dist/thumbnails/lib/defaultModelColor.js +22 -0
- package/dist/thumbnails/lib/index.d.ts +12 -0
- package/dist/thumbnails/lib/index.js +12 -0
- package/dist/thumbnails/lib/mapViewerStateToOptions.d.ts +34 -0
- package/dist/thumbnails/lib/mapViewerStateToOptions.js +69 -0
- package/dist/thumbnails/lib/offscreen-dxf-thumbnail.d.ts +16 -0
- package/dist/thumbnails/lib/offscreen-dxf-thumbnail.js +173 -0
- package/dist/thumbnails/lib/offscreen-model-thumbnail.d.ts +16 -0
- package/dist/thumbnails/lib/offscreen-model-thumbnail.js +209 -0
- package/dist/thumbnails/lib/parametricClip.d.ts +18 -0
- package/dist/thumbnails/lib/parametricClip.js +177 -0
- package/dist/thumbnails/lib/parametricShapes.d.ts +1 -0
- package/dist/thumbnails/lib/parametricShapes.js +75 -0
- package/dist/thumbnails/lib/parametricViewerState.d.ts +26 -0
- package/dist/thumbnails/lib/parametricViewerState.js +198 -0
- package/dist/thumbnails/lib/thumbnail-camera-fit.d.ts +6 -0
- package/dist/thumbnails/lib/thumbnail-camera-fit.js +292 -0
- package/dist/thumbnails/lib/thumbnail-capture.d.ts +23 -0
- package/dist/thumbnails/lib/thumbnail-capture.js +161 -0
- package/dist/thumbnails/lib/thumbnail-visibility.d.ts +12 -0
- package/dist/thumbnails/lib/thumbnail-visibility.js +97 -0
- package/dist/thumbnails/lib/viewerGrid.d.ts +13 -0
- package/dist/thumbnails/lib/viewerGrid.js +57 -0
- package/dist/thumbnails/modelCache.d.ts +56 -0
- package/dist/thumbnails/modelCache.js +165 -0
- package/dist/thumbnails/modelOutputArtifact.d.ts +19 -0
- package/dist/thumbnails/modelOutputArtifact.js +87 -0
- package/dist/thumbnails/render.d.ts +45 -0
- package/dist/thumbnails/render.js +162 -0
- package/dist/thumbnails/templates.d.ts +16 -0
- package/dist/thumbnails/templates.js +786 -0
- package/dist/thumbnails/tessellator.d.ts +33 -0
- package/dist/thumbnails/tessellator.js +349 -0
- package/dist/thumbnails/types.d.ts +233 -0
- package/dist/thumbnails/types.js +1 -0
- package/dist/thumbnails/worker.d.ts +10 -0
- package/dist/thumbnails/worker.js +119 -0
- package/dist/transform.d.ts +1 -1
- package/dist/transform.js +20 -22
- package/dist/types/elements/index.d.ts +22 -28
- package/dist/types/elements/index.js +0 -1
- package/dist/types/geometry.types.d.ts +5 -5
- package/dist/types/index.d.ts +13 -59
- package/dist/types/index.js +0 -1
- package/dist/types/issues.types.d.ts +1 -2
- package/dist/utils/bounds.d.ts +10 -11
- package/dist/utils/bounds.js +105 -84
- package/dist/utils/constants.d.ts +5 -7
- package/dist/utils/constants.js +10 -15
- package/dist/utils/elements/freedrawElement.js +6 -3
- package/dist/utils/elements/index.d.ts +2 -6
- package/dist/utils/elements/index.js +4 -9
- package/dist/utils/elements/linearElement.d.ts +12 -14
- package/dist/utils/elements/linearElement.js +81 -66
- package/dist/utils/elements/newElement.d.ts +37 -22
- package/dist/utils/elements/newElement.js +70 -64
- package/dist/utils/elements/textElement.d.ts +34 -35
- package/dist/utils/elements/textElement.js +79 -83
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/locator.d.ts +43 -0
- package/dist/utils/locator.js +112 -0
- package/dist/utils/math/bbox.d.ts +1 -2
- package/dist/utils/math/geometry.js +5 -4
- package/dist/utils/math/index.d.ts +13 -17
- package/dist/utils/math/index.js +53 -41
- package/dist/utils/math/random.js +7 -2
- package/dist/utils/normalize.d.ts +5 -5
- package/dist/utils/normalize.js +15 -10
- package/dist/utils/shape.d.ts +3 -4
- package/dist/utils/shape.js +64 -48
- package/dist/utils/state/index.d.ts +3 -4
- package/dist/utils/state/index.js +8 -23
- package/dist/wasi.js +38 -12
- package/package.json +23 -9
- package/dist/technical/index.d.ts +0 -2
- package/dist/technical/index.js +0 -2
- package/dist/technical/measurements.d.ts +0 -31
- package/dist/technical/measurements.js +0 -64
- package/dist/technical/scopes.d.ts +0 -261
- package/dist/technical/scopes.js +0 -676
- package/dist/types/typeChecks.d.ts +0 -5
- package/dist/types/typeChecks.js +0 -10
- package/dist/utils/traverse.d.ts +0 -30
- 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
|
+
}
|
package/dist/transform.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
423
|
-
* numbers
|
|
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
|
|
425
|
+
function unwrapNumericValues(obj) {
|
|
427
426
|
if (obj === null || obj === undefined)
|
|
428
427
|
return obj;
|
|
429
|
-
if (
|
|
428
|
+
if (isNumericWrapper(obj))
|
|
430
429
|
return obj.value;
|
|
431
430
|
if (Array.isArray(obj))
|
|
432
|
-
return obj.map(
|
|
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] =
|
|
440
|
+
out[key] = unwrapNumericValues(obj[key]);
|
|
442
441
|
}
|
|
443
442
|
return out;
|
|
444
443
|
}
|
|
445
444
|
return obj;
|
|
446
445
|
}
|
|
447
|
-
function
|
|
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
|
-
|
|
453
|
-
Object.keys(v).length === 2);
|
|
451
|
+
Object.keys(v).every((k) => k === "value" || k === "scaled"));
|
|
454
452
|
}
|
|
455
|
-
function
|
|
456
|
-
const
|
|
457
|
-
if (typeof
|
|
458
|
-
return
|
|
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:
|
|
476
|
-
?
|
|
477
|
-
:
|
|
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(
|
|
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:
|
|
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:
|
|
31
|
-
y:
|
|
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:
|
|
40
|
-
height:
|
|
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", "
|
|
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" | "
|
|
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: [
|
|
220
|
+
offset: [number, number];
|
|
227
221
|
/** Dash pattern (empty array = solid line) */
|
|
228
|
-
dashPattern:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
565
|
-
y:
|
|
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:
|
|
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:
|
|
639
|
-
colSpacing:
|
|
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:
|
|
767
|
-
right:
|
|
768
|
-
bottom:
|
|
769
|
-
left:
|
|
760
|
+
top: number;
|
|
761
|
+
right: number;
|
|
762
|
+
bottom: number;
|
|
763
|
+
left: number;
|
|
770
764
|
};
|
|
771
765
|
};
|
|
772
766
|
export type DucPlotStyle = {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AXIS } from "../enums";
|
|
2
|
-
import {
|
|
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:
|
|
12
|
-
minY:
|
|
13
|
-
maxX:
|
|
14
|
-
maxY:
|
|
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
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
178
|
+
* The value of the zoom adapted to the UI scale bar
|
|
211
179
|
*/
|
|
212
|
-
|
|
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;
|
package/dist/types/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Actor,
|
|
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;
|
package/dist/utils/bounds.d.ts
CHANGED
|
@@ -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 =
|
|
3
|
+
export type SV = number;
|
|
5
4
|
/**
|
|
6
5
|
* Common bounds calculation interface
|
|
7
6
|
*/
|
|
8
7
|
export interface BoundsResult {
|
|
9
|
-
minX:
|
|
10
|
-
minY:
|
|
11
|
-
maxX:
|
|
12
|
-
maxY:
|
|
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:
|
|
19
|
-
cy:
|
|
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,
|
|
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:
|
|
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:
|
|
73
|
+
export declare const getResizedElementAbsoluteCoords: (element: DucElement, nextWidth: number, nextHeight: number, normalizePoints: boolean) => Bounds;
|