ducjs 3.3.0 → 3.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.
|
@@ -144,7 +144,7 @@ export declare const isValidTextAlignValue: (value: TextAlign | undefined) => Te
|
|
|
144
144
|
export declare const isValidDecimalPlacesValue: (value: number | undefined, fallback: number) => number;
|
|
145
145
|
export declare const isValidScopeValue: (value: string | undefined, localState?: Readonly<Partial<DucLocalState>> | null, mainScope?: Scope) => Scope;
|
|
146
146
|
export declare const isValidImageStatusValue: (value: ImageStatus | undefined) => ImageStatus;
|
|
147
|
-
export declare const isValidDucHead: (value: DucHead | null | undefined, blocks: RestoredDataState["blocks"]
|
|
147
|
+
export declare const isValidDucHead: (value: DucHead | null | undefined, blocks: RestoredDataState["blocks"]) => DucHead | null;
|
|
148
148
|
export declare const isValidLineHeadValue: (value: LineHead | null | undefined) => LineHead | null;
|
|
149
149
|
export declare const isValidZoomStepValue: (value: number | undefined) => number;
|
|
150
150
|
export declare const isValidImageScaleValue: (value: [number, number] | undefined) => [number, number];
|
|
@@ -710,18 +710,20 @@ export const isValidImageStatusValue = (value) => {
|
|
|
710
710
|
return IMAGE_STATUS.PENDING;
|
|
711
711
|
return value;
|
|
712
712
|
};
|
|
713
|
-
export const isValidDucHead = (value, blocks
|
|
713
|
+
export const isValidDucHead = (value, blocks) => {
|
|
714
714
|
if (value === undefined || value === null)
|
|
715
715
|
return null;
|
|
716
716
|
const type = isValidLineHeadValue(value.type);
|
|
717
|
-
// blockId can be null - only reject if type is invalid
|
|
718
717
|
if (type === null)
|
|
719
718
|
return null;
|
|
720
719
|
const blockId = isValidBlockId(value.blockId, blocks);
|
|
720
|
+
const size = typeof value.size === "number" && Number.isFinite(value.size) && value.size > 0
|
|
721
|
+
? value.size
|
|
722
|
+
: 1;
|
|
721
723
|
return {
|
|
722
724
|
type,
|
|
723
725
|
blockId,
|
|
724
|
-
size
|
|
726
|
+
size,
|
|
725
727
|
};
|
|
726
728
|
};
|
|
727
729
|
export const isValidLineHeadValue = (value) => {
|
|
@@ -746,7 +746,7 @@ const repairBinding = (element, binding, currentScope, restoredBlocks) => {
|
|
|
746
746
|
},
|
|
747
747
|
}
|
|
748
748
|
: { point: null };
|
|
749
|
-
return Object.assign({ elementId: binding.elementId || "", focus: typeof binding.focus === "number" ? binding.focus : 0, gap: restorePrecisionValue(typeof binding.gap === "number" ? Math.max(0, binding.gap) : 0, elementScope, currentScope), head: isValidDucHead(binding.head, restoredBlocks
|
|
749
|
+
return Object.assign({ elementId: binding.elementId || "", focus: typeof binding.focus === "number" ? binding.focus : 0, gap: restorePrecisionValue(typeof binding.gap === "number" ? Math.max(0, binding.gap) : 0, elementScope, currentScope), head: isValidDucHead(binding.head, restoredBlocks), fixedPoint: element && isElbowArrow(element)
|
|
750
750
|
? normalizeFixedPoint((_a = binding.fixedPoint) !== null && _a !== void 0 ? _a : { x: 0.5, y: 0.5 })
|
|
751
751
|
: null }, pointData);
|
|
752
752
|
};
|
|
@@ -830,7 +830,7 @@ const createHeadOnlyBinding = (head, restoredBlocks, currentScope) => {
|
|
|
830
830
|
gap: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
831
831
|
fixedPoint: null,
|
|
832
832
|
point: null,
|
|
833
|
-
head: isValidDucHead(head, restoredBlocks
|
|
833
|
+
head: isValidDucHead(head, restoredBlocks),
|
|
834
834
|
};
|
|
835
835
|
};
|
|
836
836
|
const validateDeprecatedElementContent = (color, defaultContent) => {
|
package/dist/wasm.js
CHANGED
|
@@ -10,15 +10,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import init, { applyDeltaChangeset as _applyDeltaChangeset, createDeltaChangeset as _createDeltaChangeset, getCurrentSchemaVersion as _getCurrentSchemaVersion, getExternalFile as _getExternalFile, listExternalFiles as _listExternalFiles, listVersions as _listVersions, parseDuc as _parseDuc, parseDucLazy as _parseDucLazy, readVersionGraph as _readVersionGraph, restoreCheckpoint as _restoreCheckpoint, restoreVersion as _restoreVersion, revertToVersion as _revertToVersion, serializeDuc as _serializeDuc, } from "../dist/ducjs_wasm";
|
|
11
11
|
let initialized = false;
|
|
12
12
|
let initPromise = null;
|
|
13
|
+
const DEFAULT_WASM_URL = new URL("../dist/ducjs_wasm_bg.wasm", import.meta.url);
|
|
14
|
+
const isNodeRuntime = () => { var _a; return typeof process !== "undefined" && typeof ((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node) === "string"; };
|
|
15
|
+
const loadNodeFsPromises = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
17
|
+
return dynamicImport(["node", "fs/promises"].join(":"));
|
|
18
|
+
});
|
|
19
|
+
const resolveDefaultWasmInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
if (!isNodeRuntime()) {
|
|
21
|
+
return DEFAULT_WASM_URL;
|
|
22
|
+
}
|
|
23
|
+
const { readFile } = yield loadNodeFsPromises();
|
|
24
|
+
const bytes = yield readFile(DEFAULT_WASM_URL);
|
|
25
|
+
return new Uint8Array(bytes);
|
|
26
|
+
});
|
|
13
27
|
export function ensureWasm(wasmUrl) {
|
|
14
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
29
|
if (initialized)
|
|
16
30
|
return;
|
|
17
31
|
if (!initPromise) {
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
initPromise = (() => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const moduleOrPath = wasmUrl !== null && wasmUrl !== void 0 ? wasmUrl : yield resolveDefaultWasmInput();
|
|
34
|
+
yield init({ module_or_path: moduleOrPath });
|
|
20
35
|
initialized = true;
|
|
21
|
-
});
|
|
36
|
+
}))();
|
|
22
37
|
}
|
|
23
38
|
return initPromise;
|
|
24
39
|
});
|
|
@@ -31,8 +46,12 @@ export function ensureWasm(wasmUrl) {
|
|
|
31
46
|
*/
|
|
32
47
|
export function getWasmBinary() {
|
|
33
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
if (isNodeRuntime()) {
|
|
50
|
+
const { readFile } = yield loadNodeFsPromises();
|
|
51
|
+
const bytes = yield readFile(DEFAULT_WASM_URL);
|
|
52
|
+
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
53
|
+
}
|
|
54
|
+
const resp = yield fetch(DEFAULT_WASM_URL);
|
|
36
55
|
if (!resp.ok) {
|
|
37
56
|
throw new Error(`Failed to fetch WASM binary: ${resp.status} ${resp.statusText}`);
|
|
38
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ducjs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -8,11 +8,15 @@
|
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
11
12
|
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.js"
|
|
13
|
-
"types": "./dist/index.d.ts"
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
14
|
},
|
|
15
15
|
"./*": {
|
|
16
|
+
"types": [
|
|
17
|
+
"./dist/*.d.ts",
|
|
18
|
+
"./dist/*/index.d.ts"
|
|
19
|
+
],
|
|
16
20
|
"import": [
|
|
17
21
|
"./dist/*.js",
|
|
18
22
|
"./dist/*/index.js"
|
|
@@ -20,10 +24,6 @@
|
|
|
20
24
|
"require": [
|
|
21
25
|
"./dist/*.js",
|
|
22
26
|
"./dist/*/index.js"
|
|
23
|
-
],
|
|
24
|
-
"types": [
|
|
25
|
-
"./dist/*.d.ts",
|
|
26
|
-
"./dist/*/index.d.ts"
|
|
27
27
|
]
|
|
28
28
|
}
|
|
29
29
|
},
|