ducjs 3.4.4 → 3.5.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/ducjs_wasm.d.ts +1 -1
- package/dist/ducjs_wasm.js +2 -2
- package/dist/ducjs_wasm_bg.wasm +0 -0
- package/dist/lazy-files.d.ts +2 -0
- package/dist/lazy-files.js +9 -0
- package/dist/parse.js +16 -0
- package/dist/restore/restoreDataState.d.ts +15 -10
- package/dist/restore/restoreDataState.js +272 -3
- package/dist/restore/restoreElements.js +2 -1
- package/dist/technical/scopes.d.ts +1 -1
- package/dist/types/charter.types.d.ts +118 -0
- package/dist/types/charter.types.js +5 -0
- package/dist/types/elements/index.d.ts +5 -3
- package/dist/types/elements/typeChecks.d.ts +2 -2
- package/dist/types/{geometryTypes.d.ts → geometry.types.d.ts} +1 -1
- package/dist/types/index.d.ts +22 -18
- package/dist/types/index.js +4 -2
- package/dist/types/issues.types.d.ts +80 -0
- package/dist/types/utility.types.js +1 -0
- package/dist/utils/bounds.d.ts +1 -1
- package/dist/utils/elements/index.d.ts +3 -2
- package/dist/utils/elements/index.js +7 -0
- package/dist/utils/elements/linearElement.d.ts +2 -2
- package/dist/utils/elements/newElement.d.ts +1 -1
- package/dist/utils/elements/newElement.js +8 -2
- package/dist/utils/elements/textElement.d.ts +2 -2
- package/dist/utils/math/bbox.d.ts +2 -2
- package/dist/utils/math/geometry.d.ts +2 -2
- package/dist/utils/math/index.d.ts +2 -2
- package/dist/utils/state/index.d.ts +3 -1
- package/dist/utils/state/index.js +10 -1
- package/dist/version-control.d.ts +1 -1
- package/dist/version-control.js +1 -1
- package/package.json +1 -1
- /package/dist/types/{geometryTypes.js → geometry.types.js} +0 -0
- /package/dist/types/{utility-types.js → issues.types.js} +0 -0
- /package/dist/types/{utility-types.d.ts → utility.types.d.ts} +0 -0
package/dist/ducjs_wasm.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function getExternalFile(buf: Uint8Array, file_id: string): any;
|
|
|
34
34
|
* was created. Returns the full document state as `Uint8Array`.
|
|
35
35
|
*
|
|
36
36
|
* Handles all changeset formats transparently:
|
|
37
|
-
* - v3 (bsdiff), v2 (XOR diff), v1 (
|
|
37
|
+
* - v3 (bsdiff), v2 (XOR diff), v1 (gzip full snapshot)
|
|
38
38
|
*/
|
|
39
39
|
export function applyDeltaChangeset(base_state: Uint8Array, changeset: Uint8Array): Uint8Array;
|
|
40
40
|
/**
|
package/dist/ducjs_wasm.js
CHANGED
|
@@ -283,7 +283,7 @@ export function getExternalFile(buf, file_id) {
|
|
|
283
283
|
* was created. Returns the full document state as `Uint8Array`.
|
|
284
284
|
*
|
|
285
285
|
* Handles all changeset formats transparently:
|
|
286
|
-
* - v3 (bsdiff), v2 (XOR diff), v1 (
|
|
286
|
+
* - v3 (bsdiff), v2 (XOR diff), v1 (gzip full snapshot)
|
|
287
287
|
* @param {Uint8Array} base_state
|
|
288
288
|
* @param {Uint8Array} changeset
|
|
289
289
|
* @returns {Uint8Array}
|
|
@@ -415,7 +415,7 @@ export function serializeDuc(data) {
|
|
|
415
415
|
* @returns {number}
|
|
416
416
|
*/
|
|
417
417
|
export function getCurrentSchemaVersion() {
|
|
418
|
-
return
|
|
418
|
+
return 3000007;
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
/**
|
package/dist/ducjs_wasm_bg.wasm
CHANGED
|
Binary file
|
package/dist/lazy-files.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export declare class LazyExternalFileStore {
|
|
|
36
36
|
addRuntimeFile(fileId: string, file: DucExternalFile, data: Record<string, Uint8Array>): void;
|
|
37
37
|
/** Remove a runtime file. */
|
|
38
38
|
removeRuntimeFile(fileId: string): boolean;
|
|
39
|
+
/** Unload a runtime file's data from memory while keeping metadata. */
|
|
40
|
+
unloadRuntimeFileData(fileId: string): boolean;
|
|
39
41
|
/** Export all files metadata as a DucExternalFiles record. */
|
|
40
42
|
toExternalFiles(): DucExternalFiles;
|
|
41
43
|
/** Export all revision data blobs as an ExternalFilesData record. */
|
package/dist/lazy-files.js
CHANGED
|
@@ -113,6 +113,15 @@ export class LazyExternalFileStore {
|
|
|
113
113
|
removeRuntimeFile(fileId) {
|
|
114
114
|
return this.runtimeFiles.delete(fileId);
|
|
115
115
|
}
|
|
116
|
+
/** Unload a runtime file's data from memory while keeping metadata. */
|
|
117
|
+
unloadRuntimeFileData(fileId) {
|
|
118
|
+
const file = this.runtimeFiles.get(fileId);
|
|
119
|
+
if (file) {
|
|
120
|
+
file.data = {};
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
116
125
|
/** Export all files metadata as a DucExternalFiles record. */
|
|
117
126
|
toExternalFiles() {
|
|
118
127
|
const result = {};
|
package/dist/parse.js
CHANGED
|
@@ -51,6 +51,14 @@ export function parseDuc(blob, _fileHandle, elementsConfig, restoreConfig) {
|
|
|
51
51
|
if (originalVG) {
|
|
52
52
|
restored.versionGraph = originalVG;
|
|
53
53
|
}
|
|
54
|
+
// Keep charter and issues in the parsed output even though restore() does not
|
|
55
|
+
// currently populate them itself.
|
|
56
|
+
if (data.charter) {
|
|
57
|
+
restored.charter = data.charter;
|
|
58
|
+
}
|
|
59
|
+
if (data.issues) {
|
|
60
|
+
restored.issues = data.issues;
|
|
61
|
+
}
|
|
54
62
|
return restored;
|
|
55
63
|
});
|
|
56
64
|
}
|
|
@@ -90,6 +98,14 @@ export function parseDucLazy(buffer, elementsConfig, restoreConfig) {
|
|
|
90
98
|
if (originalVG) {
|
|
91
99
|
restored.versionGraph = originalVG;
|
|
92
100
|
}
|
|
101
|
+
// Keep charter and issues in the parsed output even though restore() does not
|
|
102
|
+
// currently populate them itself.
|
|
103
|
+
if (data.charter) {
|
|
104
|
+
restored.charter = data.charter;
|
|
105
|
+
}
|
|
106
|
+
if (data.issues) {
|
|
107
|
+
restored.issues = data.issues;
|
|
108
|
+
}
|
|
93
109
|
return restored;
|
|
94
110
|
});
|
|
95
111
|
}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
import { BLENDING } from "../enums";
|
|
2
|
-
import type { Checkpoint, Delta, Dictionary, DucExternalFiles, DucGlobalState, ExternalFilesData, ImportedDataState, LibraryItems, PrecisionValue, Scope
|
|
2
|
+
import type { Checkpoint, Delta, Dictionary, DucCharter, DucExternalFiles, DucGlobalState, DucIssue, ExportedDataState, ExternalFilesData, ImportedDataState, LibraryItems, PrecisionValue, Scope } from "../types";
|
|
3
3
|
import { DucLocalState } from "../types";
|
|
4
4
|
import type { _DucStackBase, BezierMirroring, DucBlock, DucBlockCollection, DucBlockInstance, DucElement, DucGroup, DucHead, DucLayer, DucRegion, ElementBackground, ElementContentBase, ElementStroke, ExternalFileId, FillStyle, ImageStatus, LineHead, OrderedDucElement, StrokeCap, StrokeJoin, StrokePreference, StrokeSidePreference, StrokeStyle, TextAlign, VerticalAlign } from "../types/elements";
|
|
5
|
-
import { Percentage, Radian } from "../types/
|
|
6
|
-
import { ValueOf } from "../types/utility
|
|
5
|
+
import { Percentage, Radian } from "../types/geometry.types";
|
|
6
|
+
import { ValueOf } from "../types/utility.types";
|
|
7
7
|
import { VERSIONS } from "../utils/constants";
|
|
8
8
|
export type RestoredLocalState = Omit<DucLocalState, "offsetTop" | "offsetLeft" | "width" | "height">;
|
|
9
9
|
export type RestoredDataState = {
|
|
10
|
-
thumbnail:
|
|
11
|
-
dictionary:
|
|
10
|
+
thumbnail: ExportedDataState["thumbnail"];
|
|
11
|
+
dictionary: ExportedDataState["dictionary"];
|
|
12
|
+
charter: ExportedDataState["charter"];
|
|
13
|
+
issues: ExportedDataState["issues"];
|
|
12
14
|
elements: OrderedDucElement[];
|
|
13
15
|
localState: RestoredLocalState;
|
|
14
|
-
globalState:
|
|
15
|
-
files: DucExternalFiles;
|
|
16
|
-
filesData: ExternalFilesData;
|
|
16
|
+
globalState: ExportedDataState["globalState"];
|
|
17
17
|
blocks: DucBlock[];
|
|
18
18
|
blockInstances: DucBlockInstance[];
|
|
19
19
|
blockCollections: DucBlockCollection[];
|
|
20
20
|
groups: DucGroup[];
|
|
21
21
|
regions: DucRegion[];
|
|
22
22
|
layers: DucLayer[];
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
files: DucExternalFiles;
|
|
24
|
+
filesData: ExternalFilesData;
|
|
25
|
+
versionGraph: ExportedDataState["versionGraph"];
|
|
26
|
+
id: ExportedDataState["id"];
|
|
25
27
|
};
|
|
26
28
|
export interface ExportedLibraryData {
|
|
27
29
|
type: string;
|
|
@@ -53,6 +55,9 @@ export declare const restoreFiles: (importedFiles: unknown, restoredFilesData?:
|
|
|
53
55
|
* Also extracts data from legacy inline `revisions[].data` when present.
|
|
54
56
|
*/
|
|
55
57
|
export declare const restoreFilesData: (importedFilesData: unknown, importedFiles: unknown) => ExternalFilesData;
|
|
58
|
+
export declare const restoreCharter: (importedCharter: unknown) => DucCharter;
|
|
59
|
+
export declare const restoreIssue: (value: unknown) => DucIssue | undefined;
|
|
60
|
+
export declare const restoreIssues: (importedIssues: unknown) => DucIssue[];
|
|
56
61
|
export declare const restoreDictionary: (importedDictionary: unknown) => Dictionary;
|
|
57
62
|
/**
|
|
58
63
|
* Restores the groups array from imported data, ensuring each item
|
|
@@ -3,7 +3,7 @@ import tinycolor from "tinycolor2";
|
|
|
3
3
|
import { BEZIER_MIRRORING, BLENDING, BOOLEAN_OPERATION, ELEMENT_CONTENT_PREFERENCE, IMAGE_STATUS, LINE_HEAD, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN, } from "../enums";
|
|
4
4
|
import { getPrecisionScope } from "../technical/measurements";
|
|
5
5
|
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, NEUTRAL_SCOPE, ScaleFactors } from "../technical/scopes";
|
|
6
|
-
import { base64ToUint8Array, getDefaultGlobalState, getDefaultLocalState, getZoom, isEncodedFunctionString, isFiniteNumber, reviveEncodedFunction, } from "../utils";
|
|
6
|
+
import { base64ToUint8Array, getDefaultCharter, getDefaultGlobalState, getDefaultLocalState, getZoom, isEncodedFunctionString, isFiniteNumber, reviveEncodedFunction, } from "../utils";
|
|
7
7
|
import { DEFAULT_ELEMENT_PROPS, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN, DEFAULT_ZOOM_STEP, MAX_ZOOM_STEP, MIN_ZOOM_STEP, } from "../utils/constants";
|
|
8
8
|
import { getDefaultStackProperties } from "../utils/elements";
|
|
9
9
|
import { restoreElements } from "./restoreElements";
|
|
@@ -22,12 +22,16 @@ export const restore = (data, elementsConfig, restoreConfig = {}) => {
|
|
|
22
22
|
const restoredVersionGraph = restoreVersionGraph(data === null || data === void 0 ? void 0 : data.versionGraph);
|
|
23
23
|
const restoredFilesData = restoreFilesData(data === null || data === void 0 ? void 0 : data.filesData, data === null || data === void 0 ? void 0 : data.files);
|
|
24
24
|
const restoredFiles = restoreFiles(data === null || data === void 0 ? void 0 : data.files, restoredFilesData);
|
|
25
|
+
const restoredCharter = restoreCharter(data === null || data === void 0 ? void 0 : data.charter);
|
|
26
|
+
const restoredIssues = restoreIssues(data === null || data === void 0 ? void 0 : data.issues);
|
|
25
27
|
// Generate a new ID if none exists or if it's empty
|
|
26
28
|
const parsedId = data === null || data === void 0 ? void 0 : data.id;
|
|
27
29
|
const restoredId = (parsedId && parsedId.trim().length > 0) ? parsedId : nanoid();
|
|
28
30
|
return {
|
|
29
31
|
dictionary: restoredDictionary,
|
|
30
32
|
thumbnail: isValidUint8Array(data === null || data === void 0 ? void 0 : data.thumbnail),
|
|
33
|
+
charter: restoredCharter,
|
|
34
|
+
issues: restoredIssues,
|
|
31
35
|
elements: restoredElements,
|
|
32
36
|
blocks: restoredBlocks,
|
|
33
37
|
blockInstances: restoredBlockInstances,
|
|
@@ -213,6 +217,271 @@ export const restoreFilesData = (importedFilesData, importedFiles) => {
|
|
|
213
217
|
}
|
|
214
218
|
return result;
|
|
215
219
|
};
|
|
220
|
+
const VALID_CHARTER_PHASES = ["intent", "review", "delivery", "closed"];
|
|
221
|
+
const VALID_ISSUE_STATUSES = ["open", "closed", "dismissed"];
|
|
222
|
+
const isValidActor = (value) => {
|
|
223
|
+
if (!value || typeof value !== "object")
|
|
224
|
+
return undefined;
|
|
225
|
+
const obj = value;
|
|
226
|
+
const identifier = isValidString(obj.identifier);
|
|
227
|
+
if (!identifier)
|
|
228
|
+
return undefined;
|
|
229
|
+
return {
|
|
230
|
+
identifier,
|
|
231
|
+
name: typeof obj.name === "string" ? obj.name : undefined,
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
const isValidStringList = (value) => {
|
|
235
|
+
if (!Array.isArray(value))
|
|
236
|
+
return undefined;
|
|
237
|
+
const list = value
|
|
238
|
+
.map((item) => (typeof item === "string" ? item : undefined))
|
|
239
|
+
.filter((item) => item !== undefined && item.length > 0);
|
|
240
|
+
return list.length > 0 ? list : undefined;
|
|
241
|
+
};
|
|
242
|
+
const isValidIdentifierList = (value) => {
|
|
243
|
+
const list = isValidStringList(value);
|
|
244
|
+
return list && list.length > 0 ? list : undefined;
|
|
245
|
+
};
|
|
246
|
+
const isValidReactions = (value) => {
|
|
247
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
248
|
+
return undefined;
|
|
249
|
+
const obj = value;
|
|
250
|
+
const result = {};
|
|
251
|
+
for (const key in obj) {
|
|
252
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
253
|
+
continue;
|
|
254
|
+
const identifiers = isValidIdentifierList(obj[key]);
|
|
255
|
+
if (identifiers) {
|
|
256
|
+
result[key] = identifiers;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
260
|
+
};
|
|
261
|
+
const restoreCharterRequirement = (value) => {
|
|
262
|
+
if (!value || typeof value !== "object")
|
|
263
|
+
return undefined;
|
|
264
|
+
const obj = value;
|
|
265
|
+
const id = isValidString(obj.id);
|
|
266
|
+
const statement = isValidString(obj.statement);
|
|
267
|
+
if (!id || !statement)
|
|
268
|
+
return undefined;
|
|
269
|
+
return {
|
|
270
|
+
id,
|
|
271
|
+
statement,
|
|
272
|
+
must: typeof obj.must === "boolean" ? obj.must : false,
|
|
273
|
+
acceptanceCriteria: isValidStringList(obj.acceptanceCriteria),
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
const restoreCharterConstraint = (value) => {
|
|
277
|
+
if (!value || typeof value !== "object")
|
|
278
|
+
return undefined;
|
|
279
|
+
const obj = value;
|
|
280
|
+
const id = isValidString(obj.id);
|
|
281
|
+
const statement = isValidString(obj.statement);
|
|
282
|
+
if (!id || !statement)
|
|
283
|
+
return undefined;
|
|
284
|
+
return {
|
|
285
|
+
id,
|
|
286
|
+
statement,
|
|
287
|
+
hard: typeof obj.hard === "boolean" ? obj.hard : false,
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
const restoreCharterDecision = (value) => {
|
|
291
|
+
if (!value || typeof value !== "object")
|
|
292
|
+
return undefined;
|
|
293
|
+
const obj = value;
|
|
294
|
+
const id = isValidString(obj.id);
|
|
295
|
+
const decision = isValidString(obj.decision);
|
|
296
|
+
const rationale = isValidString(obj.rationale);
|
|
297
|
+
const decidedAt = isFiniteNumber(obj.decidedAt) ? obj.decidedAt : 0;
|
|
298
|
+
if (!id || !decision || !rationale)
|
|
299
|
+
return undefined;
|
|
300
|
+
return {
|
|
301
|
+
id,
|
|
302
|
+
accepted: typeof obj.accepted === "boolean" ? obj.accepted : true,
|
|
303
|
+
decision,
|
|
304
|
+
rationale,
|
|
305
|
+
issueIds: isValidStringList(obj.issueIds),
|
|
306
|
+
decidedAt,
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
const restoreCharterStakeholder = (value) => {
|
|
310
|
+
if (!value || typeof value !== "object")
|
|
311
|
+
return undefined;
|
|
312
|
+
const obj = value;
|
|
313
|
+
const actor = isValidActor(obj.actor);
|
|
314
|
+
const role = isValidString(obj.role);
|
|
315
|
+
if (!actor || !role)
|
|
316
|
+
return undefined;
|
|
317
|
+
return { actor, role };
|
|
318
|
+
};
|
|
319
|
+
export const restoreCharter = (importedCharter) => {
|
|
320
|
+
if (!importedCharter || typeof importedCharter !== "object") {
|
|
321
|
+
return getDefaultCharter();
|
|
322
|
+
}
|
|
323
|
+
const obj = importedCharter;
|
|
324
|
+
const title = isValidString(obj.title);
|
|
325
|
+
if (!title) {
|
|
326
|
+
return getDefaultCharter();
|
|
327
|
+
}
|
|
328
|
+
const objective = typeof obj.objective === "string" ? obj.objective : "";
|
|
329
|
+
const rawPhase = isValidString(obj.phase) || "intent";
|
|
330
|
+
if (!VALID_CHARTER_PHASES.includes(rawPhase)) {
|
|
331
|
+
return getDefaultCharter();
|
|
332
|
+
}
|
|
333
|
+
const rawRequirements = Array.isArray(obj.requirements) ? obj.requirements : [];
|
|
334
|
+
const requirements = rawRequirements
|
|
335
|
+
.map((item) => restoreCharterRequirement(item))
|
|
336
|
+
.filter((item) => item !== undefined);
|
|
337
|
+
const rawConstraints = Array.isArray(obj.constraints) ? obj.constraints : [];
|
|
338
|
+
const constraints = rawConstraints
|
|
339
|
+
.map((item) => restoreCharterConstraint(item))
|
|
340
|
+
.filter((item) => item !== undefined);
|
|
341
|
+
const rawDecisions = Array.isArray(obj.decisions) ? obj.decisions : [];
|
|
342
|
+
const decisions = rawDecisions
|
|
343
|
+
.map((item) => restoreCharterDecision(item))
|
|
344
|
+
.filter((item) => item !== undefined);
|
|
345
|
+
const rawStakeholders = Array.isArray(obj.stakeholders) ? obj.stakeholders : [];
|
|
346
|
+
const stakeholders = rawStakeholders
|
|
347
|
+
.map((item) => restoreCharterStakeholder(item))
|
|
348
|
+
.filter((item) => item !== undefined);
|
|
349
|
+
return {
|
|
350
|
+
title,
|
|
351
|
+
description: typeof obj.description === "string" ? obj.description : undefined,
|
|
352
|
+
objective,
|
|
353
|
+
phase: rawPhase,
|
|
354
|
+
closedReason: typeof obj.closedReason === "string" ? obj.closedReason : undefined,
|
|
355
|
+
requirements,
|
|
356
|
+
constraints,
|
|
357
|
+
decisions,
|
|
358
|
+
stakeholders: stakeholders.length > 0 ? stakeholders : undefined,
|
|
359
|
+
updatedAt: isFiniteNumber(obj.updatedAt) ? obj.updatedAt : Date.now(),
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
const isValidViewer3DState = (value) => {
|
|
363
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
364
|
+
return undefined;
|
|
365
|
+
const obj = value;
|
|
366
|
+
if (!obj.camera || typeof obj.camera !== "object")
|
|
367
|
+
return undefined;
|
|
368
|
+
if (!obj.display || typeof obj.display !== "object")
|
|
369
|
+
return undefined;
|
|
370
|
+
return obj;
|
|
371
|
+
};
|
|
372
|
+
const restoreIssueAnchor = (value) => {
|
|
373
|
+
if (!value || typeof value !== "object")
|
|
374
|
+
return undefined;
|
|
375
|
+
const obj = value;
|
|
376
|
+
const type = isValidString(obj.type);
|
|
377
|
+
if (!type)
|
|
378
|
+
return undefined;
|
|
379
|
+
if (type === "canvas") {
|
|
380
|
+
const x = isValidNumber(obj.x, 0, false);
|
|
381
|
+
const y = isValidNumber(obj.y, 0, false);
|
|
382
|
+
return {
|
|
383
|
+
type: "canvas",
|
|
384
|
+
x,
|
|
385
|
+
y,
|
|
386
|
+
scope: typeof obj.scope === "string" ? obj.scope : undefined,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
if (type === "element") {
|
|
390
|
+
const elementId = isValidString(obj.elementId);
|
|
391
|
+
if (!elementId)
|
|
392
|
+
return undefined;
|
|
393
|
+
return {
|
|
394
|
+
type: "element",
|
|
395
|
+
elementId,
|
|
396
|
+
anchorX: typeof obj.anchorX === "number" && Number.isFinite(obj.anchorX) ? obj.anchorX : undefined,
|
|
397
|
+
anchorY: typeof obj.anchorY === "number" && Number.isFinite(obj.anchorY) ? obj.anchorY : undefined,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
if (type === "model") {
|
|
401
|
+
const elementId = isValidString(obj.elementId);
|
|
402
|
+
if (!elementId)
|
|
403
|
+
return undefined;
|
|
404
|
+
const point = Array.isArray(obj.point) && obj.point.length === 3
|
|
405
|
+
? obj.point
|
|
406
|
+
: undefined;
|
|
407
|
+
if (!point)
|
|
408
|
+
return undefined;
|
|
409
|
+
return {
|
|
410
|
+
type: "model",
|
|
411
|
+
elementId,
|
|
412
|
+
point,
|
|
413
|
+
normal: Array.isArray(obj.normal) && obj.normal.length === 3
|
|
414
|
+
? obj.normal
|
|
415
|
+
: undefined,
|
|
416
|
+
viewerState: isValidViewer3DState(obj.viewerState),
|
|
417
|
+
topologyId: typeof obj.topologyId === "string" ? obj.topologyId : undefined,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
return undefined;
|
|
421
|
+
};
|
|
422
|
+
const restoreIssueMessage = (value) => {
|
|
423
|
+
if (!value || typeof value !== "object")
|
|
424
|
+
return undefined;
|
|
425
|
+
const obj = value;
|
|
426
|
+
const id = isValidString(obj.id);
|
|
427
|
+
const author = isValidActor(obj.author);
|
|
428
|
+
const content = isValidString(obj.content);
|
|
429
|
+
if (!id || !author || !content)
|
|
430
|
+
return undefined;
|
|
431
|
+
return {
|
|
432
|
+
id,
|
|
433
|
+
author,
|
|
434
|
+
content,
|
|
435
|
+
replyToId: typeof obj.replyToId === "string" ? obj.replyToId : undefined,
|
|
436
|
+
reactions: isValidReactions(obj.reactions),
|
|
437
|
+
createdAt: isFiniteNumber(obj.createdAt) ? obj.createdAt : Date.now(),
|
|
438
|
+
editedAt: isFiniteNumber(obj.editedAt) ? obj.editedAt : undefined,
|
|
439
|
+
deletedAt: isFiniteNumber(obj.deletedAt) ? obj.deletedAt : undefined,
|
|
440
|
+
};
|
|
441
|
+
};
|
|
442
|
+
export const restoreIssue = (value) => {
|
|
443
|
+
if (!value || typeof value !== "object")
|
|
444
|
+
return undefined;
|
|
445
|
+
const obj = value;
|
|
446
|
+
const id = isValidString(obj.id);
|
|
447
|
+
const title = isValidString(obj.title);
|
|
448
|
+
const localId = isValidNumber(obj.localId, 0, true);
|
|
449
|
+
const status = isValidString(obj.status);
|
|
450
|
+
if (!id || !title || !status || !VALID_ISSUE_STATUSES.includes(status)) {
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
const rawMessages = Array.isArray(obj.messages) ? obj.messages : [];
|
|
454
|
+
const messages = rawMessages
|
|
455
|
+
.map((item) => restoreIssueMessage(item))
|
|
456
|
+
.filter((item) => item !== undefined);
|
|
457
|
+
const authorId = isValidString(obj.authorId);
|
|
458
|
+
if (!authorId)
|
|
459
|
+
return undefined;
|
|
460
|
+
return {
|
|
461
|
+
id,
|
|
462
|
+
localId,
|
|
463
|
+
title,
|
|
464
|
+
status: status,
|
|
465
|
+
dismissedReason: typeof obj.dismissedReason === "string" ? obj.dismissedReason : undefined,
|
|
466
|
+
messages,
|
|
467
|
+
dueDate: isFiniteNumber(obj.dueDate) ? obj.dueDate : undefined,
|
|
468
|
+
anchor: restoreIssueAnchor(obj.anchor),
|
|
469
|
+
authorId,
|
|
470
|
+
assigneeIds: isValidIdentifierList(obj.assigneeIds),
|
|
471
|
+
followerIds: isValidIdentifierList(obj.followerIds),
|
|
472
|
+
createdAt: isFiniteNumber(obj.createdAt) ? obj.createdAt : Date.now(),
|
|
473
|
+
updatedAt: isFiniteNumber(obj.updatedAt) ? obj.updatedAt : Date.now(),
|
|
474
|
+
deletedAt: isFiniteNumber(obj.deletedAt) ? obj.deletedAt : undefined,
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
export const restoreIssues = (importedIssues) => {
|
|
478
|
+
if (!Array.isArray(importedIssues)) {
|
|
479
|
+
return [];
|
|
480
|
+
}
|
|
481
|
+
return importedIssues
|
|
482
|
+
.map((item) => restoreIssue(item))
|
|
483
|
+
.filter((item) => item !== undefined);
|
|
484
|
+
};
|
|
216
485
|
export const restoreDictionary = (importedDictionary) => {
|
|
217
486
|
if (!importedDictionary || typeof importedDictionary !== "object") {
|
|
218
487
|
return {};
|
|
@@ -456,9 +725,9 @@ const restoreBlockMetadata = (metadata) => {
|
|
|
456
725
|
* @returns A complete and valid DucGlobalState object.
|
|
457
726
|
*/
|
|
458
727
|
export const restoreGlobalState = (importedState = {}) => {
|
|
459
|
-
var _a, _b
|
|
728
|
+
var _a, _b;
|
|
460
729
|
const defaults = getDefaultGlobalState();
|
|
461
|
-
return Object.assign(Object.assign({}, defaults), {
|
|
730
|
+
return Object.assign(Object.assign({}, defaults), { viewBackgroundColor: (_a = importedState === null || importedState === void 0 ? void 0 : importedState.viewBackgroundColor) !== null && _a !== void 0 ? _a : defaults.viewBackgroundColor, mainScope: (_b = isValidAppStateScopeValue(importedState === null || importedState === void 0 ? void 0 : importedState.mainScope)) !== null && _b !== void 0 ? _b : defaults.mainScope, scopeExponentThreshold: isValidAppStateScopeExponentThresholdValue(importedState === null || importedState === void 0 ? void 0 : importedState.scopeExponentThreshold, defaults.scopeExponentThreshold) });
|
|
462
731
|
};
|
|
463
732
|
/**
|
|
464
733
|
* Restores the user's local session state from imported data.
|
|
@@ -317,6 +317,7 @@ const restoreElement = (element, currentScope, restoredBlocks, localState, globa
|
|
|
317
317
|
return restoreElementWithProperties(tableElement, {
|
|
318
318
|
fileId: isValidString(tableElement.fileId) ||
|
|
319
319
|
defaultData.fileId,
|
|
320
|
+
gridConfig: restoreDocumentGridConfig(tableElement.gridConfig),
|
|
320
321
|
}, localState);
|
|
321
322
|
}
|
|
322
323
|
case "doc": {
|
|
@@ -333,7 +334,7 @@ const restoreElement = (element, currentScope, restoredBlocks, localState, globa
|
|
|
333
334
|
return restoreElementWithProperties(modelElement, {
|
|
334
335
|
modelType: isValidString(modelElement.modelType) || null,
|
|
335
336
|
code: isValidString(modelElement.code) || null,
|
|
336
|
-
fileIds: modelElement.fileIds
|
|
337
|
+
fileIds: modelElement.fileIds ? [...new Set(modelElement.fileIds)] : [],
|
|
337
338
|
thumbnail: modelElement.thumbnail instanceof Uint8Array ? modelElement.thumbnail : null,
|
|
338
339
|
viewerState: (modelElement.viewerState || null),
|
|
339
340
|
}, localState, globalState);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UNIT_SYSTEM } from "../enums";
|
|
2
2
|
import { PrecisionValue, RawValue, ScaledZoom, Scope, ScopedValue, ScopedZoomValue, ValueOf } from "../types";
|
|
3
3
|
import { DucPoint } from "../types/elements";
|
|
4
|
-
import { GeometricPoint } from "../types/
|
|
4
|
+
import { GeometricPoint } from "../types/geometry.types";
|
|
5
5
|
export type UnitSystem = ValueOf<typeof UNIT_SYSTEM>;
|
|
6
6
|
export type ZoomDirection = 'up' | 'down' | 'neutral';
|
|
7
7
|
export declare const MIN_ZOOM = 1e-32;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Charter — grounded on ISO 21500/21502
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
import { Actor } from ".";
|
|
6
|
+
/**
|
|
7
|
+
* The current phase of the pre-execution cycle.
|
|
8
|
+
*
|
|
9
|
+
* Phases are not strictly linear, they are cycles — a review that raises concerns
|
|
10
|
+
* returns the Charter to intent. Closed is terminal: use closedReason to record why.
|
|
11
|
+
*/
|
|
12
|
+
export type DucCharterPhase = "intent" | "review" | "delivery" | "closed";
|
|
13
|
+
/**
|
|
14
|
+
* A condition the project outcome must or should satisfy.
|
|
15
|
+
*
|
|
16
|
+
* Requirements define what the delivered artifact must do or be — not how to build it
|
|
17
|
+
* (that's constraints) and not what work is in scope (that's the objective).
|
|
18
|
+
*
|
|
19
|
+
* Verification evidence lives in issues, tables, plots, or linked files — not here.
|
|
20
|
+
*/
|
|
21
|
+
export interface DucCharterRequirement {
|
|
22
|
+
id: string;
|
|
23
|
+
statement: string;
|
|
24
|
+
/**
|
|
25
|
+
* true — must be met. Failure to satisfy this requirement fails the project.
|
|
26
|
+
* false — should be met, but the project can proceed if it isn't.
|
|
27
|
+
*/
|
|
28
|
+
must: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Conditions that make this requirement verifiably satisfied.
|
|
31
|
+
* Each entry should be a concrete, testable statement
|
|
32
|
+
*/
|
|
33
|
+
acceptanceCriteria?: string[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A limiting condition that bounds the solution space.
|
|
37
|
+
*
|
|
38
|
+
* Constraints define how the project can be executed or what solutions are permissible —
|
|
39
|
+
* not what the outcome must achieve (that's requirements).
|
|
40
|
+
* Explicit scope exclusions also belong here as hard constraints.
|
|
41
|
+
*/
|
|
42
|
+
export interface DucCharterConstraint {
|
|
43
|
+
id: string;
|
|
44
|
+
statement: string;
|
|
45
|
+
/**
|
|
46
|
+
* true — cannot be violated under any circumstance.
|
|
47
|
+
* false — strong preference; can be revisited with documented justification.
|
|
48
|
+
*/
|
|
49
|
+
hard: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A resolved choice significant enough to explain the current design direction.
|
|
53
|
+
*
|
|
54
|
+
* Proposals, open questions, and unresolved debate belong in issues — not here.
|
|
55
|
+
* A decision earns its place in the Charter when understanding the current artifact
|
|
56
|
+
* state requires knowing that this choice was made and why.
|
|
57
|
+
*/
|
|
58
|
+
export interface DucCharterDecision {
|
|
59
|
+
id: string;
|
|
60
|
+
/**
|
|
61
|
+
* true — decision is in effect.
|
|
62
|
+
* false — decision was considered and rejected. Kept for traceability.
|
|
63
|
+
*/
|
|
64
|
+
accepted: boolean;
|
|
65
|
+
/** The decision itself, stated as a clear and compact conclusion. */
|
|
66
|
+
decision: string;
|
|
67
|
+
/**
|
|
68
|
+
* Why this choice was made: the reasoning, the alternatives considered,
|
|
69
|
+
* and what was accepted as a consequence.
|
|
70
|
+
*/
|
|
71
|
+
rationale: string;
|
|
72
|
+
/** Issues that informed or are traceable to this decision. */
|
|
73
|
+
issueIds?: string[];
|
|
74
|
+
decidedAt: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The project-level identity and reasoning anchor.
|
|
78
|
+
*
|
|
79
|
+
* A Charter holds what an engineer or agent needs to understand what the project
|
|
80
|
+
* is trying to achieve and why the current artifact state exists.
|
|
81
|
+
*/
|
|
82
|
+
export interface DucCharter {
|
|
83
|
+
title: string;
|
|
84
|
+
/** Orientation: what kind of project this is and the context needed to read the charter */
|
|
85
|
+
description?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Why this project exists and what concrete outcome it must reach.
|
|
88
|
+
* This is the single most important field in the Charter — every requirement,
|
|
89
|
+
* constraint, and decision should be traceable back to it.
|
|
90
|
+
*/
|
|
91
|
+
objective: string;
|
|
92
|
+
phase: DucCharterPhase;
|
|
93
|
+
/** Required when phase is "closed". Records the reason for the Charter to be closed. */
|
|
94
|
+
closedReason?: string;
|
|
95
|
+
/**
|
|
96
|
+
* What the project outcome must do or be.
|
|
97
|
+
* Scope exclusions and solution-space limits belong in constraints, not here.
|
|
98
|
+
*/
|
|
99
|
+
requirements: DucCharterRequirement[];
|
|
100
|
+
/**
|
|
101
|
+
* Conditions that bound the solution space, including explicit scope exclusions.
|
|
102
|
+
* Hard constraints are non-negotiable; soft constraints are strong preferences.
|
|
103
|
+
*/
|
|
104
|
+
constraints: DucCharterConstraint[];
|
|
105
|
+
/**
|
|
106
|
+
* The resolved choices that define the current project direction.
|
|
107
|
+
* Only decisions significant enough to explain why the artifact is in its
|
|
108
|
+
* current state belong here. Everything else lives in issues.
|
|
109
|
+
*/
|
|
110
|
+
decisions: DucCharterDecision[];
|
|
111
|
+
/** Everyone with a stake in the project outcome — active contributors or not. */
|
|
112
|
+
stakeholders?: Array<{
|
|
113
|
+
actor: Actor;
|
|
114
|
+
role: string;
|
|
115
|
+
}>;
|
|
116
|
+
/** Unix epoch milliseconds of the last Charter update. */
|
|
117
|
+
updatedAt: number;
|
|
118
|
+
}
|
|
@@ -2,8 +2,8 @@ export * from "./typeChecks";
|
|
|
2
2
|
import { PrecisionValue, Scope } from "..";
|
|
3
3
|
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
4
|
import { FONT_FAMILY, FREEDRAW_EASINGS } from "../../utils/constants";
|
|
5
|
-
import { GeometricPoint, Percentage, Radian, ScaleFactor } from "../
|
|
6
|
-
import { MakeBrand, MarkNonNullable, MarkOptional, Merge, ValueOf } from "../utility
|
|
5
|
+
import { GeometricPoint, Percentage, Radian, ScaleFactor } from "../geometry.types";
|
|
6
|
+
import { MakeBrand, MarkNonNullable, MarkOptional, Merge, ValueOf } from "../utility.types";
|
|
7
7
|
/**
|
|
8
8
|
* Base styles that all elements share
|
|
9
9
|
*/
|
|
@@ -376,6 +376,8 @@ export type DucPdfElement = _DucElementBase & {
|
|
|
376
376
|
export type DucTableElement = _DucElementBase & {
|
|
377
377
|
type: "table";
|
|
378
378
|
fileId: ExternalFileId | null;
|
|
379
|
+
/** Configuration for rendering sheets in a grid layout */
|
|
380
|
+
gridConfig: DocumentGridConfig;
|
|
379
381
|
};
|
|
380
382
|
export type ImageCrop = {
|
|
381
383
|
x: number;
|
|
@@ -840,7 +842,7 @@ export type Viewer3DGrid = {
|
|
|
840
842
|
value: boolean;
|
|
841
843
|
} | {
|
|
842
844
|
type: "perPlane";
|
|
843
|
-
|
|
845
|
+
value: Viewer3DGridPlanes;
|
|
844
846
|
};
|
|
845
847
|
export type Viewer3DDisplay = {
|
|
846
848
|
wireframe: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ElementOrToolType } from "..";
|
|
2
|
-
import { Bounds, LineSegment, TuplePoint } from "../
|
|
3
|
-
import type { MarkNonNullable } from "../utility
|
|
2
|
+
import { Bounds, LineSegment, TuplePoint } from "../geometry.types";
|
|
3
|
+
import type { MarkNonNullable } from "../utility.types";
|
|
4
4
|
import type { DucArrowElement, DucBindableElement, DucDocElement, DucElbowArrowElement, DucElement, DucElementType, DucEllipseElement, DucEmbeddableElement, DucFlowchartNodeElement, DucFrameElement, DucFrameLikeElement, DucFreeDrawElement, DucIframeLikeElement, DucImageElement, DucLinearElement, DucNonSelectionElement, DucPdfElement, DucPlotElement, DucPointBinding, DucPolygonElement, DucTableElement, DucTextContainer, DucTextElement, DucTextElementWithContainer, FixedPointBinding, InitializedDucImageElement, NonDeleted } from "./";
|
|
5
5
|
export declare const isInitializedImageElement: (element: DucElement | null) => element is InitializedDucImageElement;
|
|
6
6
|
export declare const isImageElement: (element: DucElement | null) => element is DucImageElement;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
export * from "./charter.types";
|
|
1
2
|
export * from "./elements";
|
|
2
|
-
export * from "./
|
|
3
|
+
export * from "./geometry.types";
|
|
4
|
+
export * from "./issues.types";
|
|
3
5
|
export * from "./typeChecks";
|
|
4
|
-
export * from "./utility
|
|
6
|
+
export * from "./utility.types";
|
|
5
7
|
import { SupportedMeasures } from "../technical/scopes";
|
|
8
|
+
import { DucCharter } from "./charter.types";
|
|
6
9
|
import { DucBindableElement, DucBlock, DucBlockCollection, DucBlockInstance, DucElement, DucElementType, DucGroup, DucIframeLikeElement, DucLayer, DucLinearElement, DucRegion, DucTextElement, ElementBackground, ElementStroke, ExternalFileId, FontFamilyValues, LineHead, NonDeleted, TextAlign } from "./elements";
|
|
7
|
-
import { Percentage } from "./
|
|
8
|
-
import {
|
|
10
|
+
import { Percentage } from "./geometry.types";
|
|
11
|
+
import { DucIssue } from "./issues.types";
|
|
12
|
+
import { MarkOptional, MaybePromise } from "./utility.types";
|
|
9
13
|
/**
|
|
10
14
|
* Root data structure for the stored data state
|
|
11
15
|
*/
|
|
@@ -15,6 +19,8 @@ export interface ExportedDataState {
|
|
|
15
19
|
source: string;
|
|
16
20
|
thumbnail: Uint8Array | undefined;
|
|
17
21
|
dictionary: Dictionary | undefined;
|
|
22
|
+
charter: DucCharter;
|
|
23
|
+
issues: DucIssue[];
|
|
18
24
|
elements: readonly DucElement[];
|
|
19
25
|
/** The user's current session state for a specific project */
|
|
20
26
|
localState: DucLocalState;
|
|
@@ -32,7 +38,7 @@ export interface ExportedDataState {
|
|
|
32
38
|
/** In case it is needed to embed the version control into the file format */
|
|
33
39
|
versionGraph: VersionGraph | undefined;
|
|
34
40
|
/** Actual file id */
|
|
35
|
-
id: string
|
|
41
|
+
id: string;
|
|
36
42
|
}
|
|
37
43
|
export type ExportedDataStateContent = Omit<ExportedDataState, "type" | "version" | "source">;
|
|
38
44
|
export type BaseExportedDataState = MarkOptional<ExportedDataStateContent, "elements" | "localState" | "versionGraph">;
|
|
@@ -41,17 +47,19 @@ export type BaseExportedDataState = MarkOptional<ExportedDataStateContent, "elem
|
|
|
41
47
|
* This is useful for importing data where some fields might be missing.
|
|
42
48
|
*/
|
|
43
49
|
export type ImportedDataState = Partial<ExportedDataState>;
|
|
44
|
-
export type Identifier = {
|
|
45
|
-
/** Unique identifier for this standard */
|
|
46
|
-
id: string;
|
|
47
|
-
/** Human-readable name */
|
|
48
|
-
name: string;
|
|
49
|
-
/** Description of the standard */
|
|
50
|
-
description?: string;
|
|
51
|
-
};
|
|
52
50
|
export type Dictionary = {
|
|
53
51
|
[key: string]: string;
|
|
54
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* A person, organization, team, system, or agent relevant to the project.
|
|
55
|
+
*
|
|
56
|
+
* The identifier is stable within the project context: email, @username,
|
|
57
|
+
* agent ID, organization ID, role ID, or imported external identifier.
|
|
58
|
+
*/
|
|
59
|
+
export interface Actor {
|
|
60
|
+
identifier: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
}
|
|
55
63
|
export type Scope = SupportedMeasures;
|
|
56
64
|
export type ExternalFileRevisionMeta = {
|
|
57
65
|
id: string;
|
|
@@ -109,10 +117,6 @@ export type ElementOrToolType = DucElementType | ToolType | "custom";
|
|
|
109
117
|
* They travel with the file and are consistent for all users.
|
|
110
118
|
*/
|
|
111
119
|
export type DucGlobalState = {
|
|
112
|
-
/**
|
|
113
|
-
* The name of the drawing
|
|
114
|
-
*/
|
|
115
|
-
name: string | null;
|
|
116
120
|
/**
|
|
117
121
|
* The background color of the drawing
|
|
118
122
|
*/
|
|
@@ -282,7 +286,7 @@ export interface Delta extends VersionBase {
|
|
|
282
286
|
versionNumber: number;
|
|
283
287
|
schemaVersion: number;
|
|
284
288
|
baseCheckpointId: VersionId;
|
|
285
|
-
/** Compressed binary data for the delta (
|
|
289
|
+
/** Compressed binary data for the delta (gzip). */
|
|
286
290
|
payload: Uint8Array;
|
|
287
291
|
sizeBytes: number;
|
|
288
292
|
}
|
package/dist/types/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from "./charter.types";
|
|
1
2
|
export * from "./elements";
|
|
2
|
-
export * from "./
|
|
3
|
+
export * from "./geometry.types";
|
|
4
|
+
export * from "./issues.types";
|
|
3
5
|
export * from "./typeChecks";
|
|
4
|
-
export * from "./utility
|
|
6
|
+
export * from "./utility.types";
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Actor, Scope, Viewer3DState } from ".";
|
|
2
|
+
export type DucIssueStatus = "open" | "closed" | "dismissed";
|
|
3
|
+
/** A single message in an issue thread. */
|
|
4
|
+
export interface DucIssueMessage {
|
|
5
|
+
id: string;
|
|
6
|
+
author: Actor;
|
|
7
|
+
content: string;
|
|
8
|
+
/** Id of the message this message is responding to, if any. */
|
|
9
|
+
replyToId?: string;
|
|
10
|
+
/** Reactions keyed by emoji string. */
|
|
11
|
+
reactions?: Record<string, Actor["identifier"][]>;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
editedAt?: number;
|
|
14
|
+
deletedAt?: number;
|
|
15
|
+
}
|
|
16
|
+
export type DucIssueAnchor = {
|
|
17
|
+
type: "canvas";
|
|
18
|
+
/** Canvas location in drawing units. */
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
scope?: Scope;
|
|
22
|
+
} | {
|
|
23
|
+
type: "element";
|
|
24
|
+
elementId: string;
|
|
25
|
+
/** Anchor point on the attached element, in element-local units in case of referencing a specific region of the element. */
|
|
26
|
+
anchorX?: number;
|
|
27
|
+
anchorY?: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: "model";
|
|
30
|
+
/** Must reference a DucModelElement. */
|
|
31
|
+
elementId: string;
|
|
32
|
+
/**
|
|
33
|
+
* Anchor point in model-local coordinates, in the model's native units.
|
|
34
|
+
* This is the primary position used to keep the issue pinned to the model.
|
|
35
|
+
*/
|
|
36
|
+
point: [number, number, number];
|
|
37
|
+
/**
|
|
38
|
+
* Surface normal in model-local coordinates.
|
|
39
|
+
* Used to orient and offset the marker away from the surface.
|
|
40
|
+
*/
|
|
41
|
+
normal?: [number, number, number];
|
|
42
|
+
/**
|
|
43
|
+
* Viewer state at the time this issue was created.
|
|
44
|
+
* Stored separately from the element's viewerState so the inspection
|
|
45
|
+
* angle is preserved even if the model's current viewer state changes.
|
|
46
|
+
*/
|
|
47
|
+
viewerState?: Viewer3DState;
|
|
48
|
+
/**
|
|
49
|
+
* Stable CAD/BREP/IFC topology identifier, only when provided by the model pipeline.
|
|
50
|
+
* Do not derive this from renderer face indices.
|
|
51
|
+
*/
|
|
52
|
+
topologyId?: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* An issue attached to a specific location, element, or area of the drawing.
|
|
56
|
+
* Issues hold open questions, feedback, concerns, approvals, and the discussion that resolves them.
|
|
57
|
+
*/
|
|
58
|
+
export interface DucIssue {
|
|
59
|
+
id: string;
|
|
60
|
+
/**
|
|
61
|
+
* Stable, human-readable identifier within the drawing.
|
|
62
|
+
* Displayed to users as #1, #2, etc.
|
|
63
|
+
*/
|
|
64
|
+
localId: number;
|
|
65
|
+
title: string;
|
|
66
|
+
status: DucIssueStatus;
|
|
67
|
+
/** Required when the issue is dismissed. Records the reason for the dismissal. */
|
|
68
|
+
dismissedReason?: string;
|
|
69
|
+
/** Messages forming the issue discussion thread. */
|
|
70
|
+
messages: DucIssueMessage[];
|
|
71
|
+
/** Optional due date as epoch milliseconds. */
|
|
72
|
+
dueDate?: number;
|
|
73
|
+
anchor?: DucIssueAnchor;
|
|
74
|
+
authorId: Actor["identifier"];
|
|
75
|
+
assigneeIds?: Actor["identifier"][];
|
|
76
|
+
followerIds?: Actor["identifier"][];
|
|
77
|
+
createdAt: number;
|
|
78
|
+
updatedAt: number;
|
|
79
|
+
deletedAt?: number;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/bounds.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Scope, ScopedValue } from "../types";
|
|
2
2
|
import { DucElement, DucFreeDrawElement, DucLine, DucLinearElement, DucPoint, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap } from "../types/elements";
|
|
3
|
-
import { Bounds, GeometricPoint } from "../types/
|
|
3
|
+
import { Bounds, GeometricPoint } from "../types/geometry.types";
|
|
4
4
|
type SV = ScopedValue;
|
|
5
5
|
/**
|
|
6
6
|
* Common bounds calculation interface
|
|
@@ -5,8 +5,8 @@ export * from "./newElement";
|
|
|
5
5
|
export * from "./textElement";
|
|
6
6
|
import { Scope } from "../../types";
|
|
7
7
|
import { _DucStackBase, DucElement, DucNonSelectionElement, DucTableElement, DucTextStyle, ElementConstructorOpts, NonDeleted } from "../../types/elements";
|
|
8
|
-
import { GeometricPoint, TuplePoint } from "../../types/
|
|
9
|
-
import { Mutable } from "../../types/utility
|
|
8
|
+
import { GeometricPoint, TuplePoint } from "../../types/geometry.types";
|
|
9
|
+
import { Mutable } from "../../types/utility.types";
|
|
10
10
|
/**
|
|
11
11
|
* Returns a default DucTextStyle object for the given scope.
|
|
12
12
|
*/
|
|
@@ -25,6 +25,7 @@ export declare const getDefaultStackProperties: () => _DucStackBase;
|
|
|
25
25
|
*/
|
|
26
26
|
export declare const getDefaultTableData: (currentScope: Scope) => {
|
|
27
27
|
fileId: DucTableElement["fileId"];
|
|
28
|
+
gridConfig: DucTableElement["gridConfig"];
|
|
28
29
|
};
|
|
29
30
|
export declare const getBaseElementProps: (element: DucNonSelectionElement) => ElementConstructorOpts;
|
|
30
31
|
export declare function convertPointToTuple(point: GeometricPoint): TuplePoint;
|
|
@@ -58,6 +58,13 @@ export const getDefaultStackProperties = () => {
|
|
|
58
58
|
export const getDefaultTableData = (currentScope) => {
|
|
59
59
|
return {
|
|
60
60
|
fileId: null,
|
|
61
|
+
gridConfig: {
|
|
62
|
+
columns: 1,
|
|
63
|
+
gapX: 0,
|
|
64
|
+
gapY: 0,
|
|
65
|
+
firstPageAlone: false,
|
|
66
|
+
scale: 1,
|
|
67
|
+
},
|
|
61
68
|
};
|
|
62
69
|
};
|
|
63
70
|
export const getBaseElementProps = (element) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PrecisionValue, RawValue, Scope } from "../../types";
|
|
2
2
|
import type { DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, DucTextElementWithContainer, ElementsMap, NonDeleted } from "../../types/elements";
|
|
3
|
-
import { Bounds, GeometricPoint } from "../../types/
|
|
4
|
-
import type { ValueOf } from "../../types/utility
|
|
3
|
+
import { Bounds, GeometricPoint } from "../../types/geometry.types";
|
|
4
|
+
import type { ValueOf } from "../../types/utility.types";
|
|
5
5
|
import { ElementAbsoluteCoords } from "../bounds";
|
|
6
6
|
import { HANDLE_TYPE } from "../../enums";
|
|
7
7
|
export type HandleType = ValueOf<typeof HANDLE_TYPE> | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Scope } from "../../types";
|
|
2
2
|
import { DucArrowElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLinearElement, DucModelElement, DucPdfElement, DucPlotElement, DucPolygonElement, DucTableElement, DucTextElement, ElementConstructorOpts, ElementUpdate, NonDeleted } from "../../types/elements";
|
|
3
|
-
import { Mutable } from "../../types/utility
|
|
3
|
+
import { Mutable } from "../../types/utility.types";
|
|
4
4
|
export declare const newElementWith: <TElement extends DucElement>(element: TElement, updates: ElementUpdate<TElement>,
|
|
5
5
|
/** pass `true` to always regenerate */
|
|
6
6
|
force?: boolean) => TElement;
|
|
@@ -158,8 +158,14 @@ export const newImageElement = (currentScope, opts) => {
|
|
|
158
158
|
return (Object.assign(Object.assign({}, _newElementBase("image", currentScope, Object.assign(Object.assign({}, opts), getMediaElementStyle(opts)))), { type: "image", status: (_a = opts.status) !== null && _a !== void 0 ? _a : IMAGE_STATUS.PENDING, fileId: (_b = opts.fileId) !== null && _b !== void 0 ? _b : null, scaleFlip: (_c = opts.scaleFlip) !== null && _c !== void 0 ? _c : [1, 1], crop: null, filter: null }));
|
|
159
159
|
};
|
|
160
160
|
export const newTableElement = (currentScope, opts) => {
|
|
161
|
-
var _a;
|
|
162
|
-
return (Object.assign(Object.assign({}, _newElementBase("table", currentScope, opts)), { fileId: (_a = opts.fileId) !== null && _a !== void 0 ? _a : null,
|
|
161
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
162
|
+
return (Object.assign(Object.assign({}, _newElementBase("table", currentScope, opts)), { fileId: (_a = opts.fileId) !== null && _a !== void 0 ? _a : null, gridConfig: {
|
|
163
|
+
columns: (_c = (_b = opts.gridConfig) === null || _b === void 0 ? void 0 : _b.columns) !== null && _c !== void 0 ? _c : 1,
|
|
164
|
+
gapX: (_e = (_d = opts.gridConfig) === null || _d === void 0 ? void 0 : _d.gapX) !== null && _e !== void 0 ? _e : 0,
|
|
165
|
+
gapY: (_g = (_f = opts.gridConfig) === null || _f === void 0 ? void 0 : _f.gapY) !== null && _g !== void 0 ? _g : 0,
|
|
166
|
+
firstPageAlone: (_j = (_h = opts.gridConfig) === null || _h === void 0 ? void 0 : _h.firstPageAlone) !== null && _j !== void 0 ? _j : false,
|
|
167
|
+
scale: (_l = (_k = opts.gridConfig) === null || _k === void 0 ? void 0 : _k.scale) !== null && _l !== void 0 ? _l : 1,
|
|
168
|
+
}, type: "table" }));
|
|
163
169
|
};
|
|
164
170
|
export const newDocElement = (currentScope, opts) => {
|
|
165
171
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SupportedMeasures } from "../../technical/scopes";
|
|
2
2
|
import { DucLocalState, RawValue, Scope, ScopedValue } from "../../types";
|
|
3
3
|
import { DucElement, DucElementType, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap, FontFamilyValues, FontString, NonDeletedDucElement } from "../../types/elements";
|
|
4
|
-
import { GeometricPoint } from "../../types/
|
|
5
|
-
import { ExtractSetType } from "../../types/utility
|
|
4
|
+
import { GeometricPoint } from "../../types/geometry.types";
|
|
5
|
+
import { ExtractSetType } from "../../types/utility.types";
|
|
6
6
|
import { getBoundTextElementPosition } from "./linearElement";
|
|
7
7
|
export declare const computeBoundTextPosition: (container: DucElement, boundTextElement: DucTextElementWithContainer, elementsMap: ElementsMap, currentScope: SupportedMeasures) => {
|
|
8
8
|
x: ScopedValue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Bounds, LineSegment } from "../../types/
|
|
2
|
-
import { GeometricPoint } from "../../types/
|
|
1
|
+
import { Bounds, LineSegment } from "../../types/geometry.types";
|
|
2
|
+
import { GeometricPoint } from "../../types/geometry.types";
|
|
3
3
|
export declare function getBBox(line: LineSegment): Bounds;
|
|
4
4
|
export declare function crossProduct(a: GeometricPoint, b: GeometricPoint): number;
|
|
5
5
|
export declare function doBBoxesIntersect(a: Bounds, b: Bounds): boolean;
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* to pure shapes.
|
|
13
13
|
*/
|
|
14
14
|
import type { DucBindableElement } from "../../types/elements";
|
|
15
|
-
import type { LineSegment } from "../../types/
|
|
16
|
-
import type { GeometricPoint, Line, Polygon, Curve, Ellipse, Polycurve, Polyline } from "../../types/
|
|
15
|
+
import type { LineSegment } from "../../types/geometry.types";
|
|
16
|
+
import type { GeometricPoint, Line, Polygon, Curve, Ellipse, Polycurve, Polyline } from "../../types/geometry.types";
|
|
17
17
|
/**
|
|
18
18
|
* Utils
|
|
19
19
|
*/
|
|
@@ -6,8 +6,8 @@ import { SupportedMeasures } from "../../technical/scopes";
|
|
|
6
6
|
import type { Zoom } from "../../types";
|
|
7
7
|
import { Scope, ScopedValue } from "../../types";
|
|
8
8
|
import type { DucElement, DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, NonDeleted } from "../../types/elements";
|
|
9
|
-
import type { Bounds, GeometricPoint, GeometricVector, Percentage, Radian } from "../../types/
|
|
10
|
-
import { Heading } from "../../types/
|
|
9
|
+
import type { Bounds, GeometricPoint, GeometricVector, Percentage, Radian } from "../../types/geometry.types";
|
|
10
|
+
import { Heading } from "../../types/geometry.types";
|
|
11
11
|
export type NullableGridSize = number | null;
|
|
12
12
|
export declare const getRadianFromDegrees: (degrees: number) => Radian;
|
|
13
13
|
export declare const getDegreesFromRadian: (radian: Radian) => number;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { DucGlobalState, DucLocalState, Scope, Zoom } from "../../types";
|
|
1
|
+
import { DucCharter, DucGlobalState, DucIssue, DucLocalState, Scope, Zoom } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Returns the zoom object with value, scoped, and scaled properties,
|
|
4
4
|
* using importedState, restoredGlobalState, and defaults.
|
|
5
5
|
*/
|
|
6
6
|
export declare const getZoom: (value: number, mainScope: Scope, scopeExponentThreshold: number) => Zoom;
|
|
7
7
|
export declare const getDefaultGlobalState: () => DucGlobalState;
|
|
8
|
+
export declare const getDefaultCharter: () => DucCharter;
|
|
9
|
+
export declare const getDefaultIssues: () => DucIssue[];
|
|
8
10
|
export declare const getDefaultLocalState: () => Omit<DucLocalState, "offsetTop" | "offsetLeft" | "width" | "height">;
|
|
@@ -22,12 +22,21 @@ export const getZoom = (value, mainScope, scopeExponentThreshold) => {
|
|
|
22
22
|
};
|
|
23
23
|
export const getDefaultGlobalState = () => {
|
|
24
24
|
return {
|
|
25
|
-
name: null,
|
|
26
25
|
viewBackgroundColor: typeof window !== "undefined" ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? COLOR_PALETTE.night : COLOR_PALETTE.white) : COLOR_PALETTE.white,
|
|
27
26
|
scopeExponentThreshold: 3,
|
|
28
27
|
mainScope: NEUTRAL_SCOPE,
|
|
29
28
|
};
|
|
30
29
|
};
|
|
30
|
+
export const getDefaultCharter = () => ({
|
|
31
|
+
title: "",
|
|
32
|
+
objective: "",
|
|
33
|
+
phase: "intent",
|
|
34
|
+
requirements: [],
|
|
35
|
+
constraints: [],
|
|
36
|
+
decisions: [],
|
|
37
|
+
updatedAt: Date.now(),
|
|
38
|
+
});
|
|
39
|
+
export const getDefaultIssues = () => [];
|
|
31
40
|
export const getDefaultLocalState = () => {
|
|
32
41
|
const scrollX = typeof window !== "undefined" ? window.innerWidth / 2 : 0;
|
|
33
42
|
const scrollY = typeof window !== "undefined" ? window.innerHeight / 2 : 0;
|
|
@@ -82,6 +82,6 @@ export declare const createDeltaChangeset: (baseState: Uint8Array, currentState:
|
|
|
82
82
|
* was created. Returns the full document state as `Uint8Array`.
|
|
83
83
|
*
|
|
84
84
|
* Handles all changeset formats transparently:
|
|
85
|
-
* - v3 (bsdiff), v2 (XOR diff), v1 (
|
|
85
|
+
* - v3 (bsdiff), v2 (XOR diff), v1 (gzip full snapshot)
|
|
86
86
|
*/
|
|
87
87
|
export declare const applyDeltaChangeset: (baseState: Uint8Array, changeset: Uint8Array) => Promise<Uint8Array>;
|
package/dist/version-control.js
CHANGED
|
@@ -108,7 +108,7 @@ export const createDeltaChangeset = (baseState, currentState) => __awaiter(void
|
|
|
108
108
|
* was created. Returns the full document state as `Uint8Array`.
|
|
109
109
|
*
|
|
110
110
|
* Handles all changeset formats transparently:
|
|
111
|
-
* - v3 (bsdiff), v2 (XOR diff), v1 (
|
|
111
|
+
* - v3 (bsdiff), v2 (XOR diff), v1 (gzip full snapshot)
|
|
112
112
|
*/
|
|
113
113
|
export const applyDeltaChangeset = (baseState, changeset) => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
114
|
yield ensureWasm();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ducjs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.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",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|