ducjs 2.0.0 → 2.1.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/README.md +1 -1
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +0 -8
- package/dist/flatbuffers/duc/duc-leader-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-leader-style.js +0 -8
- package/dist/flatbuffers/duc/duc-plot-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-plot-style.js +1 -10
- package/dist/flatbuffers/duc/duc-table-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-table-style.js +0 -8
- package/dist/flatbuffers/duc/duc-text-style.d.ts +0 -3
- package/dist/flatbuffers/duc/duc-text-style.js +0 -8
- package/dist/flatbuffers/duc/duc-viewport-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-viewport-style.js +1 -10
- package/dist/flatbuffers/duc/duc-xray-style.d.ts +1 -4
- package/dist/flatbuffers/duc/duc-xray-style.js +1 -10
- package/dist/flatbuffers/duc/exported-data-state.d.ts +3 -0
- package/dist/flatbuffers/duc/exported-data-state.js +8 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/parse.d.ts +5 -5
- package/dist/parse.js +57 -20
- package/dist/restore/restoreDataState.d.ts +14 -10
- package/dist/restore/restoreDataState.js +29 -22
- package/dist/restore/restoreElements.d.ts +2 -2
- package/dist/restore/restoreElements.js +21 -14
- package/dist/restore/restoreStandards.d.ts +2 -2
- package/dist/restore/restoreStandards.js +4 -4
- package/dist/serialize.d.ts +3 -2
- package/dist/serialize.js +14 -27
- package/dist/technical/measurements.d.ts +2 -2
- package/dist/technical/measurements.js +1 -1
- package/dist/technical/scopes.d.ts +4 -4
- package/dist/technical/scopes.js +1 -1
- package/dist/technical/standards.d.ts +4 -4
- package/dist/types/elements/index.d.ts +13 -13
- package/dist/types/elements/typeChecks.d.ts +5 -4
- package/dist/types/elements/typeChecks.js +5 -2
- package/dist/types/geometryTypes.d.ts +2 -2
- package/dist/types/index.d.ts +11 -8
- package/dist/types/index.js +1 -0
- package/dist/types/typeChecks.d.ts +5 -0
- package/dist/types/typeChecks.js +10 -0
- package/dist/utils/bounds.d.ts +3 -3
- package/dist/utils/bounds.js +3 -3
- package/dist/utils/constants.d.ts +5 -3
- package/dist/utils/constants.js +3 -5
- package/dist/utils/elements/frameElement.d.ts +2 -1
- package/dist/utils/elements/frameElement.js +13 -1
- package/dist/utils/elements/freedrawElement.d.ts +1 -1
- package/dist/utils/elements/freedrawElement.js +1 -1
- package/dist/utils/elements/index.d.ts +4 -4
- package/dist/utils/elements/index.js +17 -21
- package/dist/utils/elements/linearElement.d.ts +6 -6
- package/dist/utils/elements/linearElement.js +4 -4
- package/dist/utils/elements/newElement.d.ts +3 -3
- package/dist/utils/elements/newElement.js +26 -26
- package/dist/utils/elements/textElement.d.ts +7 -7
- package/dist/utils/elements/textElement.js +11 -9
- package/dist/utils/elements/viewportElement.d.ts +1 -1
- package/dist/utils/functionCodec.js +2 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/math/algebra/gadirections.d.ts +1 -1
- package/dist/utils/math/algebra/gadirections.js +1 -1
- package/dist/utils/math/algebra/galines.d.ts +1 -1
- package/dist/utils/math/algebra/galines.js +1 -1
- package/dist/utils/math/algebra/gapoints.d.ts +1 -1
- package/dist/utils/math/algebra/gapoints.js +3 -3
- package/dist/utils/math/algebra/gatransforms.d.ts +1 -1
- package/dist/utils/math/algebra/gatransforms.js +2 -2
- package/dist/utils/math/bbox.d.ts +2 -2
- package/dist/utils/math/geometry.d.ts +3 -3
- package/dist/utils/math/geometry.js +2 -2
- package/dist/utils/math/index.d.ts +6 -6
- package/dist/utils/math/index.js +3 -3
- package/dist/utils/normalize.d.ts +2 -2
- package/dist/utils/normalize.js +2 -2
- package/dist/utils/shape.d.ts +2 -2
- package/dist/utils/shape.js +8 -8
- package/dist/utils/state/grid.d.ts +1 -1
- package/dist/utils/state/grid.js +3 -3
- package/dist/utils/state/index.d.ts +1 -1
- package/dist/utils/state/index.js +7 -7
- package/dist/utils/traverse.d.ts +22 -0
- package/dist/utils/traverse.js +87 -0
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/package.json +4 -2
- package/dist/legacy/index.d.ts +0 -1
- package/dist/legacy/index.js +0 -1
- package/dist/legacy/v1/duc/app-state.d.ts +0 -124
- package/dist/legacy/v1/duc/app-state.js +0 -388
- package/dist/legacy/v1/duc/binary-file-data.d.ts +0 -27
- package/dist/legacy/v1/duc/binary-file-data.js +0 -90
- package/dist/legacy/v1/duc/binary-files-entry.d.ts +0 -16
- package/dist/legacy/v1/duc/binary-files-entry.js +0 -43
- package/dist/legacy/v1/duc/binary-files.d.ts +0 -17
- package/dist/legacy/v1/duc/binary-files.js +0 -55
- package/dist/legacy/v1/duc/binding-point.d.ts +0 -15
- package/dist/legacy/v1/duc/binding-point.js +0 -48
- package/dist/legacy/v1/duc/bound-element.d.ts +0 -17
- package/dist/legacy/v1/duc/bound-element.js +0 -48
- package/dist/legacy/v1/duc/duc-block-attribute-details.d.ts +0 -22
- package/dist/legacy/v1/duc/duc-block-attribute-details.js +0 -57
- package/dist/legacy/v1/duc/duc-block-attribute.d.ts +0 -16
- package/dist/legacy/v1/duc/duc-block-attribute.js +0 -43
- package/dist/legacy/v1/duc/duc-block-instance-element-override.d.ts +0 -17
- package/dist/legacy/v1/duc/duc-block-instance-element-override.js +0 -48
- package/dist/legacy/v1/duc/duc-block.d.ts +0 -34
- package/dist/legacy/v1/duc/duc-block.js +0 -110
- package/dist/legacy/v1/duc/duc-element.d.ts +0 -273
- package/dist/legacy/v1/duc/duc-element.js +0 -865
- package/dist/legacy/v1/duc/duc-group.d.ts +0 -40
- package/dist/legacy/v1/duc/duc-group.js +0 -114
- package/dist/legacy/v1/duc/duc-line-reference.d.ts +0 -15
- package/dist/legacy/v1/duc/duc-line-reference.js +0 -43
- package/dist/legacy/v1/duc/duc-line.d.ts +0 -15
- package/dist/legacy/v1/duc/duc-line.js +0 -43
- package/dist/legacy/v1/duc/duc-path.d.ts +0 -26
- package/dist/legacy/v1/duc/duc-path.js +0 -69
- package/dist/legacy/v1/duc/duc-table-cell.d.ts +0 -22
- package/dist/legacy/v1/duc/duc-table-cell.js +0 -57
- package/dist/legacy/v1/duc/duc-table-column.d.ts +0 -18
- package/dist/legacy/v1/duc/duc-table-column.js +0 -50
- package/dist/legacy/v1/duc/duc-table-row.d.ts +0 -18
- package/dist/legacy/v1/duc/duc-table-row.js +0 -50
- package/dist/legacy/v1/duc/duc-table-style-props.d.ts +0 -39
- package/dist/legacy/v1/duc/duc-table-style-props.js +0 -114
- package/dist/legacy/v1/duc/duc-table-style.d.ts +0 -14
- package/dist/legacy/v1/duc/duc-table-style.js +0 -41
- package/dist/legacy/v1/duc/element-background.d.ts +0 -14
- package/dist/legacy/v1/duc/element-background.js +0 -41
- package/dist/legacy/v1/duc/element-content-base.d.ts +0 -22
- package/dist/legacy/v1/duc/element-content-base.js +0 -64
- package/dist/legacy/v1/duc/element-stroke.d.ts +0 -23
- package/dist/legacy/v1/duc/element-stroke.js +0 -66
- package/dist/legacy/v1/duc/exported-data-state.d.ts +0 -51
- package/dist/legacy/v1/duc/exported-data-state.js +0 -155
- package/dist/legacy/v1/duc/image-crop.d.ts +0 -23
- package/dist/legacy/v1/duc/image-crop.js +0 -80
- package/dist/legacy/v1/duc/linear-element-editor.d.ts +0 -44
- package/dist/legacy/v1/duc/linear-element-editor.js +0 -119
- package/dist/legacy/v1/duc/point-binding.d.ts +0 -25
- package/dist/legacy/v1/duc/point-binding.js +0 -72
- package/dist/legacy/v1/duc/point.d.ts +0 -20
- package/dist/legacy/v1/duc/point.js +0 -63
- package/dist/legacy/v1/duc/pointer-down-state.d.ts +0 -32
- package/dist/legacy/v1/duc/pointer-down-state.js +0 -90
- package/dist/legacy/v1/duc/renderer-state.d.ts +0 -17
- package/dist/legacy/v1/duc/renderer-state.js +0 -54
- package/dist/legacy/v1/duc/segment-midpoint-state.d.ts +0 -18
- package/dist/legacy/v1/duc/segment-midpoint-state.js +0 -57
- package/dist/legacy/v1/duc/simple-point.d.ts +0 -15
- package/dist/legacy/v1/duc/simple-point.js +0 -48
- package/dist/legacy/v1/duc/stroke-sides.d.ts +0 -23
- package/dist/legacy/v1/duc/stroke-sides.js +0 -66
- package/dist/legacy/v1/duc/stroke-style.d.ts +0 -31
- package/dist/legacy/v1/duc/stroke-style.js +0 -102
- package/dist/legacy/v1/duc/tiling-properties.d.ts +0 -21
- package/dist/legacy/v1/duc/tiling-properties.js +0 -75
- package/dist/legacy/v1/duc.d.ts +0 -35
- package/dist/legacy/v1/duc.js +0 -37
- package/dist/legacy/v1/index.d.ts +0 -1
- package/dist/legacy/v1/index.js +0 -1
- package/dist/legacy/v1/parse/index.d.ts +0 -67
- package/dist/legacy/v1/parse/index.js +0 -101
- package/dist/legacy/v1/parse/parseAppStateFromBinary.d.ts +0 -3
- package/dist/legacy/v1/parse/parseAppStateFromBinary.js +0 -139
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseBinaryFilesFromBinary.js +0 -32
- package/dist/legacy/v1/parse/parseBlockFromBinary.d.ts +0 -3
- package/dist/legacy/v1/parse/parseBlockFromBinary.js +0 -70
- package/dist/legacy/v1/parse/parseElementFromBinary.d.ts +0 -8
- package/dist/legacy/v1/parse/parseElementFromBinary.js +0 -387
- package/dist/legacy/v1/parse/parseGroupFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseGroupFromBinary.js +0 -36
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.d.ts +0 -4
- package/dist/legacy/v1/parse/parseRendererStateFromBinary.js +0 -15
- package/dist/legacy/v1/serialize/index.d.ts +0 -5
- package/dist/legacy/v1/serialize/index.js +0 -81
- package/dist/legacy/v1/serialize/serializationUtils.d.ts +0 -17
- package/dist/legacy/v1/serialize/serializationUtils.js +0 -27
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeAppStateFromDuc.js +0 -145
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeBinaryFilesFromDuc.js +0 -46
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.d.ts +0 -3
- package/dist/legacy/v1/serialize/serializeBlockFromDuc.js +0 -60
- package/dist/legacy/v1/serialize/serializeElementFromDuc.d.ts +0 -8
- package/dist/legacy/v1/serialize/serializeElementFromDuc.js +0 -435
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.d.ts +0 -3
- package/dist/legacy/v1/serialize/serializeGroupFromDuc.js +0 -37
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.d.ts +0 -4
- package/dist/legacy/v1/serialize/serializeRendererStateFromDuc.js +0 -7
- package/dist/legacy/v1/types/elements/index.d.ts +0 -480
- package/dist/legacy/v1/types/elements/index.js +0 -1
- package/dist/legacy/v1/types/elements/typeChecks.d.ts +0 -40
- package/dist/legacy/v1/types/elements/typeChecks.js +0 -179
- package/dist/legacy/v1/types/geometryTypes.d.ts +0 -78
- package/dist/legacy/v1/types/geometryTypes.js +0 -1
- package/dist/legacy/v1/types/index.d.ts +0 -496
- package/dist/legacy/v1/types/index.js +0 -1
- package/dist/legacy/v1/types/utility-types.d.ts +0 -31
- package/dist/legacy/v1/types/utility-types.js +0 -1
- package/dist/legacy/v1/utils/bounds.d.ts +0 -76
- package/dist/legacy/v1/utils/bounds.js +0 -415
- package/dist/legacy/v1/utils/constants.d.ts +0 -370
- package/dist/legacy/v1/utils/constants.js +0 -571
- package/dist/legacy/v1/utils/elements/index.d.ts +0 -26
- package/dist/legacy/v1/utils/elements/index.js +0 -108
- package/dist/legacy/v1/utils/elements/linearElement.d.ts +0 -133
- package/dist/legacy/v1/utils/elements/linearElement.js +0 -544
- package/dist/legacy/v1/utils/elements/textElement.d.ts +0 -89
- package/dist/legacy/v1/utils/elements/textElement.js +0 -563
- package/dist/legacy/v1/utils/index.d.ts +0 -26
- package/dist/legacy/v1/utils/index.js +0 -40
- package/dist/legacy/v1/utils/math/algebra/ga.d.ts +0 -63
- package/dist/legacy/v1/utils/math/algebra/ga.js +0 -268
- package/dist/legacy/v1/utils/math/algebra/gadirections.d.ts +0 -9
- package/dist/legacy/v1/utils/math/algebra/gadirections.js +0 -18
- package/dist/legacy/v1/utils/math/algebra/galines.d.ts +0 -23
- package/dist/legacy/v1/utils/math/algebra/galines.js +0 -32
- package/dist/legacy/v1/utils/math/algebra/gapoints.d.ts +0 -8
- package/dist/legacy/v1/utils/math/algebra/gapoints.js +0 -30
- package/dist/legacy/v1/utils/math/algebra/gatransforms.d.ts +0 -10
- package/dist/legacy/v1/utils/math/algebra/gatransforms.js +0 -23
- package/dist/legacy/v1/utils/math/bbox.d.ts +0 -10
- package/dist/legacy/v1/utils/math/bbox.js +0 -42
- package/dist/legacy/v1/utils/math/geometry.d.ts +0 -102
- package/dist/legacy/v1/utils/math/geometry.js +0 -790
- package/dist/legacy/v1/utils/math/index.d.ts +0 -309
- package/dist/legacy/v1/utils/math/index.js +0 -1140
- package/dist/legacy/v1/utils/math/random.d.ts +0 -4
- package/dist/legacy/v1/utils/math/random.js +0 -25
- package/dist/legacy/v1/utils/measurements.d.ts +0 -33
- package/dist/legacy/v1/utils/measurements.js +0 -65
- package/dist/legacy/v1/utils/normalize.d.ts +0 -14
- package/dist/legacy/v1/utils/normalize.js +0 -49
- package/dist/legacy/v1/utils/restore.d.ts +0 -197
- package/dist/legacy/v1/utils/restore.js +0 -1255
- package/dist/legacy/v1/utils/scopes.d.ts +0 -260
- package/dist/legacy/v1/utils/scopes.js +0 -661
- package/dist/legacy/v1/utils/standards.d.ts +0 -12
- package/dist/legacy/v1/utils/standards.js +0 -10
- package/dist/legacy/v1/utils/state/index.d.ts +0 -2
- package/dist/legacy/v1/utils/state/index.js +0 -68
- package/dist/legacy/v1/utils/url.d.ts +0 -8
- package/dist/legacy/v1/utils/url.js +0 -33
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BLENDING } from "
|
|
2
|
-
import { Standard } from "
|
|
3
|
-
import type { Dictionary, DucExternalFiles, DucGlobalState, ImportedDataState, LibraryItems, PrecisionValue, Scope, VersionGraph } from "
|
|
4
|
-
import { DucLocalState } from "
|
|
5
|
-
import type { _DucStackBase, BezierMirroring, DucBlock, DucElement, DucGroup, DucHead, DucLayer, DucRegion, ElementBackground, ElementContentBase, ElementStroke, ExternalFileId, FillStyle, ImageStatus, LineHead, OrderedDucElement, StrokeCap, StrokeJoin, StrokePreference, StrokeSidePreference, StrokeStyle, TextAlign, VerticalAlign } from "
|
|
6
|
-
import { Percentage, Radian } from "
|
|
7
|
-
import { ValueOf } from "
|
|
8
|
-
import { VERSIONS } from "
|
|
1
|
+
import { BLENDING } from "../flatbuffers/duc";
|
|
2
|
+
import { Standard } from "../technical/standards";
|
|
3
|
+
import type { Dictionary, DucExternalFiles, DucGlobalState, ImportedDataState, LibraryItems, PrecisionValue, Scope, VersionGraph } from "../types";
|
|
4
|
+
import { DucLocalState } from "../types";
|
|
5
|
+
import type { _DucStackBase, BezierMirroring, DucBlock, DucElement, DucGroup, DucHead, DucLayer, DucRegion, ElementBackground, ElementContentBase, ElementStroke, ExternalFileId, FillStyle, ImageStatus, LineHead, OrderedDucElement, StrokeCap, StrokeJoin, StrokePreference, StrokeSidePreference, StrokeStyle, TextAlign, VerticalAlign } from "../types/elements";
|
|
6
|
+
import { Percentage, Radian } from "../types/geometryTypes";
|
|
7
|
+
import { ValueOf } from "../types/utility-types";
|
|
8
|
+
import { VERSIONS } from "../utils/constants";
|
|
9
9
|
export type RestoredLocalState = Omit<DucLocalState, "offsetTop" | "offsetLeft" | "width" | "height">;
|
|
10
10
|
export type RestoredDataState = {
|
|
11
11
|
thumbnail: Uint8Array | undefined;
|
|
@@ -20,6 +20,7 @@ export type RestoredDataState = {
|
|
|
20
20
|
layers: DucLayer[];
|
|
21
21
|
standards: Standard[];
|
|
22
22
|
versionGraph: VersionGraph | undefined;
|
|
23
|
+
id: string;
|
|
23
24
|
};
|
|
24
25
|
export interface ExportedLibraryData {
|
|
25
26
|
type: string;
|
|
@@ -41,7 +42,10 @@ export type ElementsConfig = {
|
|
|
41
42
|
*/
|
|
42
43
|
passThroughElementIds?: string[];
|
|
43
44
|
};
|
|
44
|
-
export
|
|
45
|
+
export type RestoreConfig = {
|
|
46
|
+
forceScope?: Scope;
|
|
47
|
+
};
|
|
48
|
+
export declare const restore: (data: ImportedDataState | null, elementsConfig: ElementsConfig, restoreConfig?: RestoreConfig) => RestoredDataState;
|
|
45
49
|
export declare const restoreFiles: (importedFiles: unknown) => DucExternalFiles;
|
|
46
50
|
export declare const restoreDictionary: (importedDictionary: unknown) => Dictionary;
|
|
47
51
|
/**
|
|
@@ -100,7 +104,7 @@ export declare const restoreGlobalState: (importedState?: Partial<DucGlobalState
|
|
|
100
104
|
* @param restoredGlobalState - The complete and valid global state for the document.
|
|
101
105
|
* @returns A complete and valid DucLocalState object.
|
|
102
106
|
*/
|
|
103
|
-
export declare const restoreLocalState: (importedState: Partial<DucLocalState> | undefined, restoredGlobalState: RestoredDataState["globalState"], restoredStandards: RestoredDataState["standards"]) => DucLocalState;
|
|
107
|
+
export declare const restoreLocalState: (importedState: Partial<DucLocalState> | undefined, restoredGlobalState: RestoredDataState["globalState"], restoredStandards: RestoredDataState["standards"], forceScope?: Scope) => DucLocalState;
|
|
104
108
|
export declare const restoreVersionGraph: (importedGraph: any) => RestoredDataState["versionGraph"];
|
|
105
109
|
/**
|
|
106
110
|
* Restores common properties for elements leveraging _DucStackBase.
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { BEZIER_MIRRORING, BLENDING, BOOLEAN_OPERATION, ELEMENT_CONTENT_PREFERENCE, IMAGE_STATUS, LINE_HEAD, PRUNING_LEVEL, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN, } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { BEZIER_MIRRORING, BLENDING, BOOLEAN_OPERATION, ELEMENT_CONTENT_PREFERENCE, IMAGE_STATUS, LINE_HEAD, PRUNING_LEVEL, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TEXT_ALIGN, VERTICAL_ALIGN, } from "../flatbuffers/duc";
|
|
2
|
+
import { nanoid } from "nanoid";
|
|
3
|
+
import { restoreElements } from "./restoreElements";
|
|
4
|
+
import { isStandardIdPresent, restoreStandards, } from "./restoreStandards";
|
|
5
|
+
import { getPrecisionScope } from "../technical/measurements";
|
|
6
|
+
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, NEUTRAL_SCOPE, ScaleFactors } from "../technical/scopes";
|
|
7
|
+
import { PREDEFINED_STANDARDS } from "../technical/standards";
|
|
8
|
+
import { base64ToUint8Array, getDefaultGlobalState, getDefaultLocalState, getZoom, isEncodedFunctionString, isFiniteNumber, reviveEncodedFunction, } from "../utils";
|
|
9
|
+
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";
|
|
10
|
+
import { getDefaultStackProperties } from "../utils/elements";
|
|
10
11
|
import tinycolor from "tinycolor2";
|
|
11
|
-
export const restore = (data, elementsConfig) => {
|
|
12
|
+
export const restore = (data, elementsConfig, restoreConfig = {}) => {
|
|
12
13
|
const restoredStandards = restoreStandards(data === null || data === void 0 ? void 0 : data.standards);
|
|
13
14
|
const restoredDictionary = restoreDictionary(data === null || data === void 0 ? void 0 : data.dictionary);
|
|
14
15
|
const restoredGlobalState = restoreGlobalState(data === null || data === void 0 ? void 0 : data.globalState);
|
|
15
|
-
const restoredLocalState = restoreLocalState(data === null || data === void 0 ? void 0 : data.localState, restoredGlobalState, restoredStandards);
|
|
16
|
+
const restoredLocalState = restoreLocalState(data === null || data === void 0 ? void 0 : data.localState, restoredGlobalState, restoredStandards, restoreConfig.forceScope);
|
|
16
17
|
const restoredElementsConfig = Object.assign(Object.assign({}, elementsConfig), { localState: restoredLocalState });
|
|
17
18
|
const restoredBlocks = restoreBlocks(data === null || data === void 0 ? void 0 : data.blocks, restoredLocalState.scope, restoredElementsConfig);
|
|
18
19
|
const restoredRegions = restoreRegions(data === null || data === void 0 ? void 0 : data.regions);
|
|
@@ -20,6 +21,9 @@ export const restore = (data, elementsConfig) => {
|
|
|
20
21
|
const restoredLayers = restoreLayers(data === null || data === void 0 ? void 0 : data.layers, restoredLocalState.scope);
|
|
21
22
|
const restoredElements = restoreElements(data === null || data === void 0 ? void 0 : data.elements, restoredLocalState.scope, restoredBlocks, restoredElementsConfig);
|
|
22
23
|
const restoredVersionGraph = restoreVersionGraph(data === null || data === void 0 ? void 0 : data.versionGraph);
|
|
24
|
+
// Generate a new ID if none exists or if it's empty
|
|
25
|
+
const parsedId = data === null || data === void 0 ? void 0 : data.id;
|
|
26
|
+
const restoredId = (parsedId && parsedId.trim().length > 0) ? parsedId : nanoid();
|
|
23
27
|
return {
|
|
24
28
|
dictionary: restoredDictionary,
|
|
25
29
|
thumbnail: isValidUint8Array(data === null || data === void 0 ? void 0 : data.thumbnail),
|
|
@@ -33,6 +37,7 @@ export const restore = (data, elementsConfig) => {
|
|
|
33
37
|
localState: restoredLocalState,
|
|
34
38
|
globalState: restoredGlobalState,
|
|
35
39
|
files: restoreFiles(data === null || data === void 0 ? void 0 : data.files),
|
|
40
|
+
id: restoredId,
|
|
36
41
|
};
|
|
37
42
|
};
|
|
38
43
|
export const restoreFiles = (importedFiles) => {
|
|
@@ -211,13 +216,13 @@ export const restoreBlocks = (blocks, currentScope, elementsConfig) => {
|
|
|
211
216
|
* @returns A complete and valid DucGlobalState object.
|
|
212
217
|
*/
|
|
213
218
|
export const restoreGlobalState = (importedState = {}) => {
|
|
214
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
219
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
215
220
|
const defaults = getDefaultGlobalState();
|
|
216
|
-
const linearPrecision = isValidFinitePositiveByteValue(importedState.
|
|
217
|
-
return Object.assign(Object.assign({}, defaults), { name: (
|
|
221
|
+
const linearPrecision = isValidFinitePositiveByteValue((_a = importedState === null || importedState === void 0 ? void 0 : importedState.displayPrecision) === null || _a === void 0 ? void 0 : _a.linear, defaults.displayPrecision.linear);
|
|
222
|
+
return Object.assign(Object.assign({}, defaults), { name: (_b = importedState === null || importedState === void 0 ? void 0 : importedState.name) !== null && _b !== void 0 ? _b : defaults.name, viewBackgroundColor: (_c = importedState === null || importedState === void 0 ? void 0 : importedState.viewBackgroundColor) !== null && _c !== void 0 ? _c : defaults.viewBackgroundColor, mainScope: (_d = isValidAppStateScopeValue(importedState === null || importedState === void 0 ? void 0 : importedState.mainScope)) !== null && _d !== void 0 ? _d : defaults.mainScope, scopeExponentThreshold: isValidAppStateScopeExponentThresholdValue(importedState === null || importedState === void 0 ? void 0 : importedState.scopeExponentThreshold, defaults.scopeExponentThreshold), dashSpacingScale: (_e = importedState === null || importedState === void 0 ? void 0 : importedState.dashSpacingScale) !== null && _e !== void 0 ? _e : defaults.dashSpacingScale, isDashSpacingAffectedByViewportScale: (_f = importedState === null || importedState === void 0 ? void 0 : importedState.isDashSpacingAffectedByViewportScale) !== null && _f !== void 0 ? _f : defaults.isDashSpacingAffectedByViewportScale, dimensionsAssociativeByDefault: (_g = importedState === null || importedState === void 0 ? void 0 : importedState.dimensionsAssociativeByDefault) !== null && _g !== void 0 ? _g : defaults.dimensionsAssociativeByDefault, useAnnotativeScaling: (_h = importedState === null || importedState === void 0 ? void 0 : importedState.useAnnotativeScaling) !== null && _h !== void 0 ? _h : defaults.useAnnotativeScaling, displayPrecision: {
|
|
218
223
|
linear: linearPrecision,
|
|
219
|
-
angular: (
|
|
220
|
-
}, pruningLevel: importedState.pruningLevel &&
|
|
224
|
+
angular: (_k = (_j = importedState === null || importedState === void 0 ? void 0 : importedState.displayPrecision) === null || _j === void 0 ? void 0 : _j.angular) !== null && _k !== void 0 ? _k : defaults.displayPrecision.angular,
|
|
225
|
+
}, pruningLevel: (importedState === null || importedState === void 0 ? void 0 : importedState.pruningLevel) &&
|
|
221
226
|
Object.values(PRUNING_LEVEL).includes(importedState.pruningLevel)
|
|
222
227
|
? importedState.pruningLevel
|
|
223
228
|
: PRUNING_LEVEL.BALANCED });
|
|
@@ -231,16 +236,18 @@ export const restoreGlobalState = (importedState = {}) => {
|
|
|
231
236
|
* @param restoredGlobalState - The complete and valid global state for the document.
|
|
232
237
|
* @returns A complete and valid DucLocalState object.
|
|
233
238
|
*/
|
|
234
|
-
export const restoreLocalState = (importedState = {}, restoredGlobalState, restoredStandards) => {
|
|
239
|
+
export const restoreLocalState = (importedState = {}, restoredGlobalState, restoredStandards, forceScope) => {
|
|
235
240
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
236
241
|
const defaults = getDefaultLocalState();
|
|
237
|
-
const zoom = getZoom((_b = (_a = importedState.zoom) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : defaults.zoom.value, restoredGlobalState.mainScope, restoredGlobalState.scopeExponentThreshold);
|
|
238
|
-
const scope =
|
|
239
|
-
|
|
242
|
+
const zoom = getZoom((_b = (_a = importedState === null || importedState === void 0 ? void 0 : importedState.zoom) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : defaults.zoom.value, restoredGlobalState.mainScope, restoredGlobalState.scopeExponentThreshold);
|
|
243
|
+
const scope = forceScope
|
|
244
|
+
? isValidScopeValue(forceScope)
|
|
245
|
+
: isValidPrecisionScopeValue(zoom.value, restoredGlobalState.mainScope, restoredGlobalState.scopeExponentThreshold);
|
|
246
|
+
return Object.assign(Object.assign(Object.assign({}, defaults), importedState), { scope, activeStandardId: isValidStandardId(importedState === null || importedState === void 0 ? void 0 : importedState.activeStandardId, restoredStandards, defaults.activeStandardId), isBindingEnabled: isValidBoolean(importedState === null || importedState === void 0 ? void 0 : importedState.isBindingEnabled, defaults.isBindingEnabled), penMode: isValidBoolean(importedState === null || importedState === void 0 ? void 0 : importedState.penMode, defaults.penMode), scrollX: (importedState === null || importedState === void 0 ? void 0 : importedState.scrollX)
|
|
240
247
|
? restorePrecisionValue(importedState.scrollX, NEUTRAL_SCOPE, scope)
|
|
241
|
-
: getPrecisionValueFromRaw(defaults.scrollX.value, NEUTRAL_SCOPE, scope), scrollY: importedState.scrollY
|
|
248
|
+
: getPrecisionValueFromRaw(defaults.scrollX.value, NEUTRAL_SCOPE, scope), scrollY: (importedState === null || importedState === void 0 ? void 0 : importedState.scrollY)
|
|
242
249
|
? restorePrecisionValue(importedState.scrollY, NEUTRAL_SCOPE, scope)
|
|
243
|
-
: getPrecisionValueFromRaw(defaults.scrollY.value, NEUTRAL_SCOPE, scope), zoom, activeGridSettings: (_c = importedState.activeGridSettings) !== null && _c !== void 0 ? _c : defaults.activeGridSettings, activeSnapSettings: (_d = importedState.activeSnapSettings) !== null && _d !== void 0 ? _d : defaults.activeSnapSettings, currentItemStroke: (_e = validateStroke(importedState.currentItemStroke, scope, scope)) !== null && _e !== void 0 ? _e : defaults.currentItemStroke, currentItemBackground: (_f = validateBackground(importedState.currentItemBackground)) !== null && _f !== void 0 ? _f : defaults.currentItemBackground, currentItemOpacity: isValidPercentageValue(importedState.currentItemOpacity, defaults.currentItemOpacity), currentItemStartLineHead: (_g = isValidLineHeadValue(importedState.currentItemStartLineHead)) !== null && _g !== void 0 ? _g : defaults.currentItemStartLineHead, currentItemEndLineHead: (_h = isValidLineHeadValue(importedState.currentItemEndLineHead)) !== null && _h !== void 0 ? _h : defaults.currentItemEndLineHead });
|
|
250
|
+
: getPrecisionValueFromRaw(defaults.scrollY.value, NEUTRAL_SCOPE, scope), zoom, activeGridSettings: (_c = importedState === null || importedState === void 0 ? void 0 : importedState.activeGridSettings) !== null && _c !== void 0 ? _c : defaults.activeGridSettings, activeSnapSettings: (_d = importedState === null || importedState === void 0 ? void 0 : importedState.activeSnapSettings) !== null && _d !== void 0 ? _d : defaults.activeSnapSettings, currentItemStroke: (_e = validateStroke(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemStroke, scope, scope)) !== null && _e !== void 0 ? _e : defaults.currentItemStroke, currentItemBackground: (_f = validateBackground(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemBackground)) !== null && _f !== void 0 ? _f : defaults.currentItemBackground, currentItemOpacity: isValidPercentageValue(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemOpacity, defaults.currentItemOpacity), currentItemStartLineHead: (_g = isValidLineHeadValue(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemStartLineHead)) !== null && _g !== void 0 ? _g : defaults.currentItemStartLineHead, currentItemEndLineHead: (_h = isValidLineHeadValue(importedState === null || importedState === void 0 ? void 0 : importedState.currentItemEndLineHead)) !== null && _h !== void 0 ? _h : defaults.currentItemEndLineHead });
|
|
244
251
|
};
|
|
245
252
|
export const restoreVersionGraph = (importedGraph) => {
|
|
246
253
|
if (!importedGraph || typeof importedGraph !== "object") {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ElementsConfig, RestoredDataState } from "
|
|
2
|
-
import { BezierMirroring, DucElement, DucFreeDrawEasing, DucLocalState, DucPoint, ImportedDataState, OrderedDucElement, PrecisionValue, Scope } from "
|
|
1
|
+
import { ElementsConfig, RestoredDataState } from "./restoreDataState";
|
|
2
|
+
import { BezierMirroring, DucElement, DucFreeDrawEasing, DucLocalState, DucPoint, ImportedDataState, OrderedDucElement, PrecisionValue, Scope } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* Restores a point that might have legacy format (x,y as numbers)
|
|
5
5
|
* @param point - The point to restore
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isValidBezierMirroringValue, isValidBlendingValue, isValidBoolean, isValidBoolean as isValidBooleanValue, // Renaming to avoid conflict
|
|
2
|
-
isValidColor, isValidDucHead, isValidEnumValue, isValidFunction, isValidImageScaleValue, isValidImageStatusValue, isValidPercentageValue, isValidPolygonSides, isValidRadianValue, isValidString, isValidTextAlignValue, isValidVerticalAlignValue, restoreDucStackProperties, restorePrecisionValue, validateBackground, validateStroke } from "
|
|
3
|
-
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScaledZoomValueForScope, getScopedBezierPointFromDucPoint, getScopedZoomValue, NEUTRAL_SCOPE, ScaleFactors, } from "
|
|
4
|
-
import { isElbowArrow, isLinearElement, isTextElement, } from "
|
|
5
|
-
import { arrayToMap, bumpVersion, DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, detectLineHeight, FONT_FAMILY, getContainerElement, getDefaultLocalState, getDefaultTableData, getNormalizedDimensions, getNormalizedPoints, getNormalizedZoom, getSizeFromPoints, getUpdatedTimestamp, isFiniteNumber, isInvisiblySmallElement, LINE_CONFIRM_THRESHOLD, mergeOverlappingPoints, migratePoints, normalizeFixedPoint, normalizeLink, randomId, refreshTextDimensions, validateClosedPath, } from "
|
|
6
|
-
import { AXIS, BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, GDT_SYMBOL, LEADER_CONTENT_TYPE, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT, } from "
|
|
2
|
+
isValidColor, isValidDucHead, isValidEnumValue, isValidFunction, isValidImageScaleValue, isValidImageStatusValue, isValidPercentageValue, isValidPolygonSides, isValidRadianValue, isValidString, isValidTextAlignValue, isValidVerticalAlignValue, restoreDucStackProperties, restorePrecisionValue, validateBackground, validateStroke } from "./restoreDataState";
|
|
3
|
+
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScaledZoomValueForScope, getScopedBezierPointFromDucPoint, getScopedZoomValue, NEUTRAL_SCOPE, ScaleFactors, } from "../technical/scopes";
|
|
4
|
+
import { isElbowArrow, isLinearElement, isTextElement, } from "../types";
|
|
5
|
+
import { arrayToMap, bumpVersion, DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, detectLineHeight, FONT_FAMILY, getContainerElement, getDefaultLocalState, getDefaultTableData, getNormalizedDimensions, getNormalizedPoints, getNormalizedZoom, getSizeFromPoints, getUpdatedTimestamp, isFiniteNumber, isInvisiblySmallElement, LINE_CONFIRM_THRESHOLD, mergeOverlappingPoints, migratePoints, normalizeFixedPoint, normalizeLink, randomId, refreshTextDimensions, validateClosedPath, } from "../utils";
|
|
6
|
+
import { AXIS, BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, GDT_SYMBOL, LEADER_CONTENT_TYPE, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT, } from "../flatbuffers/duc";
|
|
7
7
|
import tinycolor from "tinycolor2";
|
|
8
8
|
const restoreElementWithProperties = (element, extra, localState, globalState) => {
|
|
9
9
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -1258,17 +1258,24 @@ const restoreFcfDatumDefinition = (def, elementScope, currentScope, restoredBloc
|
|
|
1258
1258
|
const restoreTextStyle = (style, currentScope) => {
|
|
1259
1259
|
var _a, _b, _c;
|
|
1260
1260
|
const defaultLineHeight = 1.15;
|
|
1261
|
-
return
|
|
1262
|
-
? { background: style.background.map(validateBackground) }
|
|
1263
|
-
: { background: [DEFAULT_ELEMENT_PROPS.background] })), ((style === null || style === void 0 ? void 0 : style.stroke)
|
|
1264
|
-
? {
|
|
1265
|
-
stroke: style.stroke.map((s) => validateStroke(s, NEUTRAL_SCOPE, currentScope)),
|
|
1266
|
-
}
|
|
1267
|
-
: { stroke: [DEFAULT_ELEMENT_PROPS.stroke] })), { roundness: restorePrecisionValue(style === null || style === void 0 ? void 0 : style.roundness, NEUTRAL_SCOPE, currentScope, DEFAULT_ELEMENT_PROPS.roundness.value), opacity: isValidPercentageValue(style === null || style === void 0 ? void 0 : style.opacity, DEFAULT_ELEMENT_PROPS.opacity), blending: isValidBlendingValue(style === null || style === void 0 ? void 0 : style.blending),
|
|
1261
|
+
return {
|
|
1268
1262
|
// Text-specific styles
|
|
1269
|
-
isLtr: isValidBoolean(style === null || style === void 0 ? void 0 : style.isLtr, true),
|
|
1263
|
+
isLtr: isValidBoolean(style === null || style === void 0 ? void 0 : style.isLtr, true),
|
|
1264
|
+
fontFamily: getFontFamilyByName(style === null || style === void 0 ? void 0 : style.fontFamily),
|
|
1265
|
+
bigFontFamily: isValidString(style === null || style === void 0 ? void 0 : style.bigFontFamily, "sans-serif"),
|
|
1266
|
+
textAlign: isValidTextAlignValue(style === null || style === void 0 ? void 0 : style.textAlign),
|
|
1267
|
+
verticalAlign: isValidVerticalAlignValue(style === null || style === void 0 ? void 0 : style.verticalAlign),
|
|
1268
|
+
lineHeight: (_a = style === null || style === void 0 ? void 0 : style.lineHeight) !== null && _a !== void 0 ? _a : defaultLineHeight,
|
|
1269
|
+
lineSpacing: restoreLineSpacing(style === null || style === void 0 ? void 0 : style.lineSpacing, (_b = style === null || style === void 0 ? void 0 : style.lineHeight) !== null && _b !== void 0 ? _b : defaultLineHeight.valueOf(), currentScope),
|
|
1270
|
+
obliqueAngle: isValidRadianValue(style === null || style === void 0 ? void 0 : style.obliqueAngle, 0),
|
|
1271
|
+
fontSize: restorePrecisionValue(style === null || style === void 0 ? void 0 : style.fontSize, NEUTRAL_SCOPE, currentScope, DEFAULT_FONT_SIZE),
|
|
1272
|
+
paperTextHeight: (style === null || style === void 0 ? void 0 : style.paperTextHeight)
|
|
1270
1273
|
? restorePrecisionValue(style.paperTextHeight, NEUTRAL_SCOPE, currentScope)
|
|
1271
|
-
: undefined,
|
|
1274
|
+
: undefined,
|
|
1275
|
+
widthFactor: (_c = style === null || style === void 0 ? void 0 : style.widthFactor) !== null && _c !== void 0 ? _c : 1,
|
|
1276
|
+
isUpsideDown: isValidBoolean(style === null || style === void 0 ? void 0 : style.isUpsideDown, false),
|
|
1277
|
+
isBackwards: isValidBoolean(style === null || style === void 0 ? void 0 : style.isBackwards, false),
|
|
1278
|
+
};
|
|
1272
1279
|
};
|
|
1273
1280
|
const restoreHeadsOverride = (heads, restoredBlocks, elementScope, currentScope) => {
|
|
1274
1281
|
if (!Array.isArray(heads) || heads.length !== 2)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Standard } from "
|
|
2
|
-
import { Scope } from "
|
|
1
|
+
import { Standard } from "../technical/standards";
|
|
2
|
+
import { Scope } from "../types";
|
|
3
3
|
export declare const restoreStandards: (standards: any, currentScope?: Scope) => Standard[];
|
|
4
4
|
/**
|
|
5
5
|
* Checks if a given id is present in the standards array.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT, GRID_DISPLAY_TYPE, GRID_TYPE, UNIT_SYSTEM, } from "
|
|
2
|
-
import { isValidBoolean, isValidEnumValue, isValidRadianValue, isValidString, restorePrecisionValue } from "
|
|
3
|
-
import { NEUTRAL_SCOPE, ScaleFactors } from "
|
|
4
|
-
import { PREDEFINED_STANDARDS } from "
|
|
1
|
+
import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT, GRID_DISPLAY_TYPE, GRID_TYPE, UNIT_SYSTEM, } from "../flatbuffers/duc";
|
|
2
|
+
import { isValidBoolean, isValidEnumValue, isValidRadianValue, isValidString, restorePrecisionValue } from "./restoreDataState";
|
|
3
|
+
import { NEUTRAL_SCOPE, ScaleFactors } from "../technical";
|
|
4
|
+
import { PREDEFINED_STANDARDS } from "../technical/standards";
|
|
5
5
|
export const restoreStandards = (standards,
|
|
6
6
|
// Pass current scope to resolve precision values if needed
|
|
7
7
|
currentScope = NEUTRAL_SCOPE) => {
|
package/dist/serialize.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { ImportedDataState } from "
|
|
1
|
+
import { ImportedDataState } from "./types";
|
|
2
|
+
import { RestoreConfig } from "./restore";
|
|
2
3
|
export declare const DUC_SCHEMA_VERSION: any;
|
|
3
|
-
export declare const serializeDuc: (data: ImportedDataState, useScopedValues?: boolean, passThroughElementIds?: string[]) => Promise<Uint8Array>;
|
|
4
|
+
export declare const serializeDuc: (data: ImportedDataState, useScopedValues?: boolean, passThroughElementIds?: string[], restoreConfig?: RestoreConfig) => Promise<Uint8Array>;
|
package/dist/serialize.js
CHANGED
|
@@ -16,10 +16,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
16
|
cast to number at the final write site (e.g. pv.value).
|
|
17
17
|
- Keep args strongly typed. Never use any for function args.
|
|
18
18
|
*/
|
|
19
|
-
import * as Duc from "ducjs/flatbuffers/duc";
|
|
20
19
|
import * as flatbuffers from "flatbuffers";
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
20
|
+
import * as Duc from "./flatbuffers/duc";
|
|
21
|
+
import { restore } from "./restore";
|
|
22
|
+
import { encodeFunctionString, EXPORT_DATA_TYPES } from "./utils";
|
|
23
23
|
/**
|
|
24
24
|
* Basic helpers
|
|
25
25
|
*/
|
|
@@ -584,13 +584,10 @@ function writeLineSpacing(b, ls, usv) {
|
|
|
584
584
|
return Duc.LineSpacing.endLineSpacing(b);
|
|
585
585
|
}
|
|
586
586
|
function writeTextStyle(b, s, usv) {
|
|
587
|
-
const base = writeStylesBase(b, s, usv);
|
|
588
587
|
const lineSpacing = writeLineSpacing(b, s.lineSpacing, usv);
|
|
589
588
|
const fontFamily = str(b, s.fontFamily.toString());
|
|
590
589
|
const bigFont = str(b, s.bigFontFamily);
|
|
591
590
|
Duc.DucTextStyle.startDucTextStyle(b);
|
|
592
|
-
if (base)
|
|
593
|
-
Duc.DucTextStyle.addBaseStyle(b, base);
|
|
594
591
|
Duc.DucTextStyle.addIsLtr(b, s.isLtr);
|
|
595
592
|
if (fontFamily)
|
|
596
593
|
Duc.DucTextStyle.addFontFamily(b, fontFamily);
|
|
@@ -879,11 +876,8 @@ function writePlotLayout(b, l, usv) {
|
|
|
879
876
|
}
|
|
880
877
|
function writePlot(b, e, usv) {
|
|
881
878
|
const stackBase = writeStackElementBase(b, e, usv);
|
|
882
|
-
const baseStyle = writeStylesBase(b, e, usv);
|
|
883
879
|
const plotStyle = (() => {
|
|
884
880
|
Duc.DucPlotStyle.startDucPlotStyle(b);
|
|
885
|
-
if (baseStyle)
|
|
886
|
-
Duc.DucPlotStyle.addBaseStyle(b, baseStyle);
|
|
887
881
|
return Duc.DucPlotStyle.endDucPlotStyle(b);
|
|
888
882
|
})();
|
|
889
883
|
const layout = writePlotLayout(b, e.layout, usv);
|
|
@@ -910,10 +904,7 @@ function writeView(b, v, usv) {
|
|
|
910
904
|
return Duc.DucView.endDucView(b);
|
|
911
905
|
}
|
|
912
906
|
function writeViewportStyle(b, s, usv) {
|
|
913
|
-
const base = writeStylesBase(b, s, usv);
|
|
914
907
|
Duc.DucViewportStyle.startDucViewportStyle(b);
|
|
915
|
-
if (base)
|
|
916
|
-
Duc.DucViewportStyle.addBaseStyle(b, base);
|
|
917
908
|
Duc.DucViewportStyle.addScaleIndicatorVisible(b, s.scaleIndicatorVisible);
|
|
918
909
|
return Duc.DucViewportStyle.endDucViewportStyle(b);
|
|
919
910
|
}
|
|
@@ -940,11 +931,8 @@ function writeViewport(b, e, usv) {
|
|
|
940
931
|
return Duc.DucViewportElement.endDucViewportElement(b);
|
|
941
932
|
}
|
|
942
933
|
function writeXRayStyle(b, s, usv) {
|
|
943
|
-
const base = writeStylesBase(b, s, usv);
|
|
944
934
|
const color = b.createString(s.color);
|
|
945
935
|
Duc.DucXRayStyle.startDucXRayStyle(b);
|
|
946
|
-
if (base)
|
|
947
|
-
Duc.DucXRayStyle.addBaseStyle(b, base);
|
|
948
936
|
Duc.DucXRayStyle.addColor(b, color);
|
|
949
937
|
return Duc.DucXRayStyle.endDucXRayStyle(b);
|
|
950
938
|
}
|
|
@@ -999,12 +987,9 @@ function writeLeaderContent(b, c, usv) {
|
|
|
999
987
|
return Duc.LeaderContent.endLeaderContent(b);
|
|
1000
988
|
}
|
|
1001
989
|
function writeLeaderStyle(b, s, usv) {
|
|
1002
|
-
const base = writeStylesBase(b, s, usv);
|
|
1003
990
|
const text = writeTextStyle(b, s.textStyle, usv);
|
|
1004
991
|
const heads = s.headsOverride ? Duc.DucLeaderStyle.createHeadsOverrideVector(b, s.headsOverride.map((h) => writeHead(b, h, usv))) : undefined;
|
|
1005
992
|
Duc.DucLeaderStyle.startDucLeaderStyle(b);
|
|
1006
|
-
if (base)
|
|
1007
|
-
Duc.DucLeaderStyle.addBaseStyle(b, base);
|
|
1008
993
|
if (heads)
|
|
1009
994
|
Duc.DucLeaderStyle.addHeadsOverride(b, heads);
|
|
1010
995
|
if (s.dogleg !== undefined)
|
|
@@ -1249,7 +1234,6 @@ function writeFcfDatumDefinition(b, d, usv) {
|
|
|
1249
1234
|
return Duc.FCFDatumDefinition.endFCFDatumDefinition(b);
|
|
1250
1235
|
}
|
|
1251
1236
|
function writeFcfStyle(b, s, usv) {
|
|
1252
|
-
const base = writeStylesBase(b, s, usv);
|
|
1253
1237
|
const text = writeTextStyle(b, s.textStyle, usv);
|
|
1254
1238
|
const layout = (() => {
|
|
1255
1239
|
Duc.FCFLayoutStyle.startFCFLayoutStyle(b);
|
|
@@ -1269,8 +1253,6 @@ function writeFcfStyle(b, s, usv) {
|
|
|
1269
1253
|
return Duc.FCFDatumStyle.endFCFDatumStyle(b);
|
|
1270
1254
|
})();
|
|
1271
1255
|
Duc.DucFeatureControlFrameStyle.startDucFeatureControlFrameStyle(b);
|
|
1272
|
-
if (base)
|
|
1273
|
-
Duc.DucFeatureControlFrameStyle.addBaseStyle(b, base);
|
|
1274
1256
|
Duc.DucFeatureControlFrameStyle.addTextStyle(b, text);
|
|
1275
1257
|
Duc.DucFeatureControlFrameStyle.addLayout(b, layout);
|
|
1276
1258
|
Duc.DucFeatureControlFrameStyle.addSymbols(b, sym);
|
|
@@ -1386,21 +1368,19 @@ function writeTableCellStyle(b, s, usv) {
|
|
|
1386
1368
|
Duc.Margins.addLeft(b, getPrecisionValue(s.margins.left, usv));
|
|
1387
1369
|
const margins = Duc.Margins.endMargins(b);
|
|
1388
1370
|
Duc.DucTableCellStyle.startDucTableCellStyle(b);
|
|
1389
|
-
if (base)
|
|
1371
|
+
if (base) {
|
|
1390
1372
|
Duc.DucTableCellStyle.addBaseStyle(b, base);
|
|
1373
|
+
}
|
|
1391
1374
|
Duc.DucTableCellStyle.addTextStyle(b, text);
|
|
1392
1375
|
Duc.DucTableCellStyle.addMargins(b, margins);
|
|
1393
1376
|
Duc.DucTableCellStyle.addAlignment(b, s.alignment);
|
|
1394
1377
|
return Duc.DucTableCellStyle.endDucTableCellStyle(b);
|
|
1395
1378
|
}
|
|
1396
1379
|
function writeTableStyle(b, s, usv) {
|
|
1397
|
-
const base = writeStylesBase(b, s, usv);
|
|
1398
1380
|
const header = writeTableCellStyle(b, s.headerRowStyle, usv);
|
|
1399
1381
|
const dataRow = writeTableCellStyle(b, s.dataRowStyle, usv);
|
|
1400
1382
|
const dataCol = writeTableCellStyle(b, s.dataColumnStyle, usv);
|
|
1401
1383
|
Duc.DucTableStyle.startDucTableStyle(b);
|
|
1402
|
-
if (base)
|
|
1403
|
-
Duc.DucTableStyle.addBaseStyle(b, base);
|
|
1404
1384
|
Duc.DucTableStyle.addFlowDirection(b, s.flowDirection);
|
|
1405
1385
|
Duc.DucTableStyle.addHeaderRowStyle(b, header);
|
|
1406
1386
|
Duc.DucTableStyle.addDataRowStyle(b, dataRow);
|
|
@@ -2369,13 +2349,13 @@ function serializeExternalFiles(builder, files, usv) {
|
|
|
2369
2349
|
export const DUC_SCHEMA_VERSION = (typeof process !== "undefined" && process.env && process.env.DUC_SCHEMA_VERSION) ||
|
|
2370
2350
|
(typeof import.meta !== "undefined" && import.meta.env && import.meta.env.DUC_SCHEMA_VERSION) ||
|
|
2371
2351
|
"0.0.0";
|
|
2372
|
-
export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, useScopedValues = false, passThroughElementIds = []) {
|
|
2352
|
+
export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ...args_1], void 0, function* (data, useScopedValues = false, passThroughElementIds = [], restoreConfig = {}) {
|
|
2373
2353
|
const builder = new flatbuffers.Builder(1024);
|
|
2374
2354
|
const sanitized = restore(data, {
|
|
2375
2355
|
refreshDimensions: false,
|
|
2376
2356
|
syncInvalidIndices: (elements) => elements,
|
|
2377
2357
|
passThroughElementIds
|
|
2378
|
-
});
|
|
2358
|
+
}, restoreConfig);
|
|
2379
2359
|
const typeOffset = builder.createString(EXPORT_DATA_TYPES.duc);
|
|
2380
2360
|
const sourceOffset = builder.createString(typeof window !== "undefined" ? window.location.origin : "unknown");
|
|
2381
2361
|
const versionOffset = builder.createString(DUC_SCHEMA_VERSION);
|
|
@@ -2422,6 +2402,10 @@ export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ..
|
|
|
2422
2402
|
const thumbnailOffset = sanitized.thumbnail
|
|
2423
2403
|
? builder.createByteVector(sanitized.thumbnail)
|
|
2424
2404
|
: null;
|
|
2405
|
+
// Serialize id (as string if present)
|
|
2406
|
+
const idOffset = sanitized.id
|
|
2407
|
+
? builder.createString(sanitized.id)
|
|
2408
|
+
: null;
|
|
2425
2409
|
Duc.ExportedDataState.startExportedDataState(builder);
|
|
2426
2410
|
Duc.ExportedDataState.addType(builder, typeOffset);
|
|
2427
2411
|
Duc.ExportedDataState.addVersion(builder, versionOffset);
|
|
@@ -2458,6 +2442,9 @@ export const serializeDuc = (data_1, ...args_1) => __awaiter(void 0, [data_1, ..
|
|
|
2458
2442
|
if (thumbnailOffset) {
|
|
2459
2443
|
Duc.ExportedDataState.addThumbnail(builder, thumbnailOffset);
|
|
2460
2444
|
}
|
|
2445
|
+
if (idOffset) {
|
|
2446
|
+
Duc.ExportedDataState.addId(builder, idOffset);
|
|
2447
|
+
}
|
|
2461
2448
|
const exportedDataStateOffset = Duc.ExportedDataState.endExportedDataState(builder);
|
|
2462
2449
|
builder.finish(exportedDataStateOffset, "DUC_");
|
|
2463
2450
|
return builder.asUint8Array();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DucElement } from "
|
|
2
|
-
import { CombinedMeasure, SupportedMeasures } from "
|
|
1
|
+
import { DucElement } from "../types/elements";
|
|
2
|
+
import { CombinedMeasure, SupportedMeasures } from "./scopes";
|
|
3
3
|
/**
|
|
4
4
|
* Gets translation factor between current scope and element scope
|
|
5
5
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { UNIT_SYSTEM } from "
|
|
2
|
-
import { PrecisionValue, RawValue, ScaledZoom, Scope, ScopedValue, ScopedZoomValue, ValueOf } from "
|
|
3
|
-
import { DucPoint } from "
|
|
4
|
-
import { GeometricPoint } from "
|
|
1
|
+
import { UNIT_SYSTEM } from "../flatbuffers/duc";
|
|
2
|
+
import { PrecisionValue, RawValue, ScaledZoom, Scope, ScopedValue, ScopedZoomValue, ValueOf } from "../types";
|
|
3
|
+
import { DucPoint } from "../types/elements";
|
|
4
|
+
import { GeometricPoint } from "../types/geometryTypes";
|
|
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;
|
package/dist/technical/scopes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT } from "
|
|
2
|
-
import { UnitSystem } from "
|
|
3
|
-
import { DucCommonStyle, DucDimensionStyle, DucDocStyle, DucFeatureControlFrameStyle, DucHatchStyle, DucLeaderStyle, DucStackLikeStyles, DucTableStyle, DucTextStyle, DucUcs, DucView, DucViewportStyle, DucXRayStyle, GridSettings, Identifier, PrecisionValue, Scope, SnapSettings, StrokeStyle } from "
|
|
4
|
-
import { ValueOf } from "
|
|
1
|
+
import { ANGULAR_UNITS_FORMAT, DECIMAL_SEPARATOR, DIMENSION_UNITS_FORMAT } from "../flatbuffers/duc";
|
|
2
|
+
import { UnitSystem } from "./scopes";
|
|
3
|
+
import { DucCommonStyle, DucDimensionStyle, DucDocStyle, DucFeatureControlFrameStyle, DucHatchStyle, DucLeaderStyle, DucStackLikeStyles, DucTableStyle, DucTextStyle, DucUcs, DucView, DucViewportStyle, DucXRayStyle, GridSettings, Identifier, PrecisionValue, Scope, SnapSettings, StrokeStyle } from "../types";
|
|
4
|
+
import { ValueOf } from "../types/utility-types";
|
|
5
5
|
export declare const PREDEFINED_STANDARDS: {
|
|
6
6
|
readonly DUC: "duc";
|
|
7
7
|
readonly ISO_25300: "iso-25300-2013";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from "./typeChecks";
|
|
2
|
-
import { BEZIER_MIRRORING, BLENDING, BLOCK_ATTACHMENT, BOOLEAN_OPERATION, COLUMN_TYPE, DATUM_BRACKET_STYLE, DATUM_TARGET_TYPE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, ELEMENT_CONTENT_PREFERENCE, FEATURE_MODIFIER, GDT_SYMBOL, HATCH_STYLE, IMAGE_STATUS, LINE_HEAD, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_ALIGN, TEXT_FIELD_SOURCE_PROPERTY, TEXT_FIELD_SOURCE_TYPE, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_TYPE, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "
|
|
3
|
-
import { Standard, StandardUnits } from "
|
|
4
|
-
import { DucView, PrecisionValue, Scope } from "
|
|
5
|
-
import { Axis, GeometricPoint, Percentage, Radian, ScaleFactor } from "
|
|
6
|
-
import { MakeBrand, MarkNonNullable, MarkOptional, Merge, ValueOf } from "
|
|
7
|
-
import { FONT_FAMILY, FREEDRAW_EASINGS } from "
|
|
2
|
+
import { BEZIER_MIRRORING, BLENDING, BLOCK_ATTACHMENT, BOOLEAN_OPERATION, COLUMN_TYPE, DATUM_BRACKET_STYLE, DATUM_TARGET_TYPE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, ELEMENT_CONTENT_PREFERENCE, FEATURE_MODIFIER, GDT_SYMBOL, HATCH_STYLE, IMAGE_STATUS, LINE_HEAD, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, PARAMETRIC_SOURCE_TYPE, STACKED_TEXT_ALIGN, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_ALIGN, TEXT_FIELD_SOURCE_PROPERTY, TEXT_FIELD_SOURCE_TYPE, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_TYPE, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "../../flatbuffers/duc";
|
|
3
|
+
import { Standard, StandardUnits } from "../../technical/standards";
|
|
4
|
+
import { DucView, PrecisionValue, Scope } from "..";
|
|
5
|
+
import { Axis, GeometricPoint, Percentage, Radian, ScaleFactor } from "../geometryTypes";
|
|
6
|
+
import { MakeBrand, MarkNonNullable, MarkOptional, Merge, ValueOf } from "../utility-types";
|
|
7
|
+
import { FONT_FAMILY, FREEDRAW_EASINGS } from "../../utils/constants";
|
|
8
8
|
/**
|
|
9
9
|
* Base styles that all elements share
|
|
10
10
|
*/
|
|
@@ -341,7 +341,7 @@ export type DucTableCellStyle = _DucElementStylesBase & {
|
|
|
341
341
|
* It sets the defaults for rows, columns, and cells, which can be
|
|
342
342
|
* individually overridden.
|
|
343
343
|
*/
|
|
344
|
-
export type DucTableStyle =
|
|
344
|
+
export type DucTableStyle = {
|
|
345
345
|
/** The direction in which new rows are added */
|
|
346
346
|
flowDirection: TableFlowDirection;
|
|
347
347
|
/** Default style for the header row(s) */
|
|
@@ -453,7 +453,7 @@ export type TextAlign = ValueOf<typeof TEXT_ALIGN>;
|
|
|
453
453
|
export type VerticalAlign = ValueOf<typeof VERTICAL_ALIGN>;
|
|
454
454
|
export type LineSpacingType = ValueOf<typeof LINE_SPACING_TYPE>;
|
|
455
455
|
export type TextFieldSourceProperty = ValueOf<typeof TEXT_FIELD_SOURCE_PROPERTY>;
|
|
456
|
-
export type DucTextStyle =
|
|
456
|
+
export type DucTextStyle = {
|
|
457
457
|
/**
|
|
458
458
|
* Whether the text is left-to-right or right-to-left
|
|
459
459
|
* @default true
|
|
@@ -845,7 +845,7 @@ export type ViewportShadePlot = ValueOf<typeof VIEWPORT_SHADE_PLOT>;
|
|
|
845
845
|
* This is the style for the viewport element
|
|
846
846
|
* Grid settings, UCS, Snapping and more can be overridden through the overrideStandard property from the _DucStackElementBase
|
|
847
847
|
*/
|
|
848
|
-
export type DucViewportStyle =
|
|
848
|
+
export type DucViewportStyle = {
|
|
849
849
|
scaleIndicatorVisible: boolean;
|
|
850
850
|
};
|
|
851
851
|
export type DucViewportElement = _DucLinearElementBase & _DucStackBase & DucViewportStyle & {
|
|
@@ -873,7 +873,7 @@ export type PlotLayout = {
|
|
|
873
873
|
left: PrecisionValue;
|
|
874
874
|
};
|
|
875
875
|
};
|
|
876
|
-
export type DucPlotStyle =
|
|
876
|
+
export type DucPlotStyle = {};
|
|
877
877
|
/**
|
|
878
878
|
* A DucPlotElement represents a finite layout or "paper space" within the infinite canvas.
|
|
879
879
|
* It serves as a container for viewports and other annotations, defining the final
|
|
@@ -885,7 +885,7 @@ export type DucPlotElement = _DucStackElementBase & DucPlotStyle & {
|
|
|
885
885
|
/** The layout definition for this plot, including paper size and margins. */
|
|
886
886
|
layout: PlotLayout;
|
|
887
887
|
};
|
|
888
|
-
export type DucXRayStyle =
|
|
888
|
+
export type DucXRayStyle = {
|
|
889
889
|
/**
|
|
890
890
|
* The color of the x-ray
|
|
891
891
|
*/
|
|
@@ -906,7 +906,7 @@ export type BlockAttachment = ValueOf<typeof BLOCK_ATTACHMENT>;
|
|
|
906
906
|
/**
|
|
907
907
|
* Defines the visual appearance and behavior of a leader.
|
|
908
908
|
*/
|
|
909
|
-
export type DucLeaderStyle =
|
|
909
|
+
export type DucLeaderStyle = {
|
|
910
910
|
/**
|
|
911
911
|
* Override the heads of the leader
|
|
912
912
|
* The tuple represents [startHead, endHead]
|
|
@@ -1161,7 +1161,7 @@ export type FeatureControlFrameSegment = {
|
|
|
1161
1161
|
* Defines the visual appearance of a Feature Control Frame.
|
|
1162
1162
|
* This can be stored in a style library and reused.
|
|
1163
1163
|
*/
|
|
1164
|
-
export type DucFeatureControlFrameStyle =
|
|
1164
|
+
export type DucFeatureControlFrameStyle = {
|
|
1165
1165
|
/** The base text style for numbers and letters within the frame */
|
|
1166
1166
|
textStyle: DucTextStyle;
|
|
1167
1167
|
/** Layout and spacing properties */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ElementOrToolType } from "
|
|
2
|
-
import type { MarkNonNullable } from "
|
|
3
|
-
import { Bounds, LineSegment, TuplePoint } from "
|
|
4
|
-
import type { DucArrowElement, DucBindableElement, DucElbowArrowElement, DucElement, DucElementType, DucEmbeddableElement, DucFlowchartNodeElement, DucFrameElement, DucFrameLikeElement, DucFreeDrawElement, DucImageElement, DucLinearElement, DucTableElement, DucPointBinding, DucTextContainer, DucTextElement, DucTextElementWithContainer, FixedPointBinding, InitializedDucImageElement, DucNonSelectionElement, DucEllipseElement, DucPolygonElement, DucBlockInstanceElement, NonDeleted, DucIframeLikeElement } from "
|
|
1
|
+
import type { ElementOrToolType } from "..";
|
|
2
|
+
import type { MarkNonNullable } from "../utility-types";
|
|
3
|
+
import { Bounds, LineSegment, TuplePoint } from "../geometryTypes";
|
|
4
|
+
import type { DucArrowElement, DucBindableElement, DucElbowArrowElement, DucElement, DucElementType, DucEmbeddableElement, DucFlowchartNodeElement, DucFrameElement, DucFrameLikeElement, DucFreeDrawElement, DucImageElement, DucLinearElement, DucPlotElement, DucTableElement, DucPointBinding, DucTextContainer, DucTextElement, DucTextElementWithContainer, FixedPointBinding, InitializedDucImageElement, DucNonSelectionElement, DucEllipseElement, DucPolygonElement, DucBlockInstanceElement, NonDeleted, DucIframeLikeElement } 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;
|
|
7
7
|
export declare const isEmbeddableElement: (element: DucElement | null | undefined) => element is DucEmbeddableElement;
|
|
@@ -9,6 +9,7 @@ export declare const isTableElement: (element: DucElement | null) => element is
|
|
|
9
9
|
export declare const isIframeLikeElement: (element: DucElement | null) => element is DucIframeLikeElement;
|
|
10
10
|
export declare const isTextElement: (element: DucElement | null) => element is DucTextElement;
|
|
11
11
|
export declare const isFrameElement: (element: DucElement | null) => element is DucFrameElement;
|
|
12
|
+
export declare const isPlotElement: (element: DucElement | null) => element is DucPlotElement;
|
|
12
13
|
export declare const isFrameLikeElement: (element: DucElement | null) => element is DucFrameLikeElement;
|
|
13
14
|
export declare const isFreeDrawElement: (element?: DucElement | null) => element is DucFreeDrawElement;
|
|
14
15
|
export declare const isEllipseElement: (element?: DucElement | null) => element is DucEllipseElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertNever } from "
|
|
1
|
+
import { assertNever } from "../../utils";
|
|
2
2
|
export const isInitializedImageElement = (element) => {
|
|
3
3
|
return !!element && element.type === "image" && !!element.fileId;
|
|
4
4
|
};
|
|
@@ -22,9 +22,12 @@ export const isTextElement = (element) => {
|
|
|
22
22
|
export const isFrameElement = (element) => {
|
|
23
23
|
return element != null && element.type === "frame";
|
|
24
24
|
};
|
|
25
|
+
export const isPlotElement = (element) => {
|
|
26
|
+
return element != null && element.type === "plot";
|
|
27
|
+
};
|
|
25
28
|
export const isFrameLikeElement = (element) => {
|
|
26
29
|
return (element != null &&
|
|
27
|
-
(element.type === "frame"));
|
|
30
|
+
(element.type === "frame" || element.type === "plot"));
|
|
28
31
|
};
|
|
29
32
|
export const isFreeDrawElement = (element) => {
|
|
30
33
|
return element != null && isFreeDrawElementType(element.type);
|