ducjs 4.2.0 → 4.4.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_bg.wasm +0 -0
- package/dist/ducjs_wasi.wasm +0 -0
- package/dist/ducjs_wasm.d.ts +2 -2
- package/dist/ducjs_wasm.js +7 -7
- package/dist/ducjs_wasm_bg.wasm +0 -0
- package/dist/ducjs_wasm_bg.wasm.d.ts +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/locator-runtime.js +1 -1
- package/dist/restore/restoreDataState.js +11 -4
- package/dist/thumbnails/browserRunner.js +1 -1
- package/dist/thumbnails/lib/clientBundle.min.js +1179 -1010
- package/dist/thumbnails/lib/offscreen-model-thumbnail.js +4 -0
- package/dist/thumbnails/lib/parametricClip.js +37 -21
- package/dist/thumbnails/lib/parametricViewerState.js +15 -11
- package/dist/types/charter.types.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/utils/compactComponentRegistry.d.ts +63 -0
- package/dist/utils/compactComponentRegistry.js +180 -0
- package/dist/utils/modelMotion.d.ts +38 -0
- package/dist/utils/modelMotion.js +160 -0
- package/dist/utils/state/index.d.ts +2 -0
- package/dist/utils/state/index.js +12 -0
- package/dist/utils/viewerUpdateBatch.d.ts +11 -0
- package/dist/utils/viewerUpdateBatch.js +34 -0
- package/package.json +2 -2
|
@@ -5,5 +5,7 @@ import { DucCharter, DucGlobalState, DucIssue, DucLocalState, Zoom } from "../..
|
|
|
5
5
|
export declare const getZoom: (value: number) => Zoom;
|
|
6
6
|
export declare const getDefaultGlobalState: () => DucGlobalState;
|
|
7
7
|
export declare const getDefaultCharter: () => DucCharter;
|
|
8
|
+
/** Record a phase transition once and preserve the reason after a charter reopens. */
|
|
9
|
+
export declare function setCharterPhase(charter: DucCharter, phase: DucCharter["phase"], reason?: string, changedAt?: number): DucCharter;
|
|
8
10
|
export declare const getDefaultIssues: () => DucIssue[];
|
|
9
11
|
export declare const getDefaultLocalState: () => Omit<DucLocalState, "offsetTop" | "offsetLeft" | "width" | "height">;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nanoid } from "nanoid";
|
|
1
2
|
import { isFiniteNumber } from "..";
|
|
2
3
|
import { TEXT_ALIGN } from "../../enums";
|
|
3
4
|
import { COLOR_PALETTE, DEFAULT_ELEMENT_PROPS, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, } from "../constants";
|
|
@@ -17,6 +18,7 @@ export const getZoom = (value) => {
|
|
|
17
18
|
export const getDefaultGlobalState = () => {
|
|
18
19
|
return {
|
|
19
20
|
viewBackgroundColor: COLOR_PALETTE.white,
|
|
21
|
+
lockBackgroundColor: false,
|
|
20
22
|
};
|
|
21
23
|
};
|
|
22
24
|
export const getDefaultCharter = () => ({
|
|
@@ -28,6 +30,16 @@ export const getDefaultCharter = () => ({
|
|
|
28
30
|
decisions: [],
|
|
29
31
|
updatedAt: Date.now(),
|
|
30
32
|
});
|
|
33
|
+
/** Record a phase transition once and preserve the reason after a charter reopens. */
|
|
34
|
+
export function setCharterPhase(charter, phase, reason, changedAt = Date.now()) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (phase === charter.phase)
|
|
37
|
+
return charter;
|
|
38
|
+
const closedReason = phase === "closed" ? reason === null || reason === void 0 ? void 0 : reason.trim() : undefined;
|
|
39
|
+
if (phase === "closed" && !closedReason)
|
|
40
|
+
throw new Error("A closing reason is required.");
|
|
41
|
+
return Object.assign(Object.assign({}, charter), { phase, closedReason, updatedAt: changedAt, phaseHistory: [...(_a = charter.phaseHistory) !== null && _a !== void 0 ? _a : [], Object.assign({ id: nanoid(), previousPhase: charter.phase, phase, changedAt }, (closedReason ? { closedReason } : {}))] });
|
|
42
|
+
}
|
|
31
43
|
export const getDefaultIssues = () => [];
|
|
32
44
|
export const getDefaultLocalState = () => {
|
|
33
45
|
const scrollX = typeof window !== "undefined" ? window.innerWidth / 2 : 0;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a sequence of three-cad-viewer mutations with at most one repaint.
|
|
3
|
+
*
|
|
4
|
+
* Every viewer setter repaints the whole scene. Restoring a saved view or
|
|
5
|
+
* syncing size after a render runs many of them in one task, and on dense
|
|
6
|
+
* clipped models each repaint redraws every solid plus its stencil caps.
|
|
7
|
+
* The viewer's own `_suppressUpdate` guard skips the intermediate paints;
|
|
8
|
+
* the final paint only happens if something inside the batch requested one.
|
|
9
|
+
* Nested batches defer to the outermost one.
|
|
10
|
+
*/
|
|
11
|
+
export declare const withBatchedViewerUpdates: <T>(viewer: unknown, apply: () => T) => T;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a sequence of three-cad-viewer mutations with at most one repaint.
|
|
3
|
+
*
|
|
4
|
+
* Every viewer setter repaints the whole scene. Restoring a saved view or
|
|
5
|
+
* syncing size after a render runs many of them in one task, and on dense
|
|
6
|
+
* clipped models each repaint redraws every solid plus its stencil caps.
|
|
7
|
+
* The viewer's own `_suppressUpdate` guard skips the intermediate paints;
|
|
8
|
+
* the final paint only happens if something inside the batch requested one.
|
|
9
|
+
* Nested batches defer to the outermost one.
|
|
10
|
+
*/
|
|
11
|
+
export const withBatchedViewerUpdates = (viewer, apply) => {
|
|
12
|
+
const target = viewer;
|
|
13
|
+
const update = target === null || target === void 0 ? void 0 : target.update;
|
|
14
|
+
if (!target || !update || target._suppressUpdate) {
|
|
15
|
+
return apply();
|
|
16
|
+
}
|
|
17
|
+
let requested = false;
|
|
18
|
+
let notify = false;
|
|
19
|
+
target._suppressUpdate = true;
|
|
20
|
+
target.update = (_updateMarker, shouldNotify = true) => {
|
|
21
|
+
requested = true;
|
|
22
|
+
notify || (notify = shouldNotify);
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
return apply();
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
target.update = update;
|
|
29
|
+
target._suppressUpdate = false;
|
|
30
|
+
if (requested) {
|
|
31
|
+
update.call(target, true, notify);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ducjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "SQLite-backed project-state format for physical-engineering work before execution.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"dxf-renderer": "^1.1.1",
|
|
58
58
|
"semantic-release": "^25.0.9",
|
|
59
59
|
"three": "^0.186.1",
|
|
60
|
-
"three-cad-viewer": "^5.1
|
|
60
|
+
"three-cad-viewer": "^5.2.1",
|
|
61
61
|
"turbo": "^2.11.10",
|
|
62
62
|
"typedoc": "^0.27.9",
|
|
63
63
|
"typescript": "^5.9.3",
|