ducjs 2.3.0 → 3.0.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 +2 -2
- package/dist/enums.d.ts +135 -0
- package/dist/enums.js +155 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +8 -4
- package/dist/lazy-files.d.ts +44 -0
- package/dist/lazy-files.js +129 -0
- package/dist/parse.d.ts +21 -55
- package/dist/parse.js +58 -1445
- package/dist/restore/index.d.ts +0 -1
- package/dist/restore/index.js +0 -1
- package/dist/restore/restoreDataState.d.ts +6 -10
- package/dist/restore/restoreDataState.js +117 -127
- package/dist/restore/restoreElements.d.ts +1 -1
- package/dist/restore/restoreElements.js +37 -494
- package/dist/serialize.d.ts +11 -4
- package/dist/serialize.js +58 -2545
- package/dist/technical/index.d.ts +0 -1
- package/dist/technical/index.js +0 -1
- package/dist/technical/scopes.d.ts +1 -1
- package/dist/technical/scopes.js +1 -1
- package/dist/transform.d.ts +12 -0
- package/dist/transform.js +442 -0
- package/dist/types/elements/index.d.ts +120 -693
- package/dist/types/elements/typeChecks.d.ts +6 -3
- package/dist/types/elements/typeChecks.js +9 -8
- package/dist/types/geometryTypes.d.ts +1 -1
- package/dist/types/index.d.ts +38 -305
- package/dist/utils/constants.d.ts +21 -100
- package/dist/utils/constants.js +29 -212
- package/dist/utils/elements/freedrawElement.d.ts +6 -0
- package/dist/utils/elements/freedrawElement.js +28 -11
- package/dist/utils/elements/index.d.ts +3 -14
- package/dist/utils/elements/index.js +7 -99
- package/dist/utils/elements/linearElement.d.ts +2 -2
- package/dist/utils/elements/newElement.d.ts +2 -12
- package/dist/utils/elements/newElement.js +32 -52
- package/dist/utils/elements/textElement.d.ts +3 -3
- package/dist/utils/elements/textElement.js +44 -17
- package/dist/utils/math/index.d.ts +5 -4
- package/dist/utils/math/index.js +3 -3
- package/dist/utils/shape.js +2 -2
- package/dist/utils/state/index.d.ts +0 -1
- package/dist/utils/state/index.js +5 -71
- package/dist/utils/traverse.d.ts +8 -0
- package/dist/utils/traverse.js +37 -0
- package/dist/version-control.d.ts +61 -0
- package/dist/version-control.js +84 -0
- package/dist/wasm.d.ts +20 -0
- package/dist/wasm.js +52 -0
- package/package.json +2 -2
- package/dist/flatbuffers/duc/alternate-units.d.ts +0 -21
- package/dist/flatbuffers/duc/alternate-units.js +0 -66
- package/dist/flatbuffers/duc/angular-unit-system.d.ts +0 -17
- package/dist/flatbuffers/duc/angular-unit-system.js +0 -50
- package/dist/flatbuffers/duc/angular-units-format.d.ts +0 -7
- package/dist/flatbuffers/duc/angular-units-format.js +0 -10
- package/dist/flatbuffers/duc/axis.d.ts +0 -5
- package/dist/flatbuffers/duc/axis.js +0 -8
- package/dist/flatbuffers/duc/bezier-mirroring.d.ts +0 -5
- package/dist/flatbuffers/duc/bezier-mirroring.js +0 -8
- package/dist/flatbuffers/duc/blending.d.ts +0 -9
- package/dist/flatbuffers/duc/blending.js +0 -12
- package/dist/flatbuffers/duc/block-attachment.d.ts +0 -4
- package/dist/flatbuffers/duc/block-attachment.js +0 -7
- package/dist/flatbuffers/duc/boolean-operation.d.ts +0 -6
- package/dist/flatbuffers/duc/boolean-operation.js +0 -9
- package/dist/flatbuffers/duc/bound-element.d.ts +0 -17
- package/dist/flatbuffers/duc/bound-element.js +0 -48
- package/dist/flatbuffers/duc/checkpoint.d.ts +0 -22
- package/dist/flatbuffers/duc/checkpoint.js +0 -75
- package/dist/flatbuffers/duc/column-layout.d.ts +0 -22
- package/dist/flatbuffers/duc/column-layout.js +0 -72
- package/dist/flatbuffers/duc/column-type.d.ts +0 -5
- package/dist/flatbuffers/duc/column-type.js +0 -8
- package/dist/flatbuffers/duc/custom-hatch-pattern.d.ts +0 -23
- package/dist/flatbuffers/duc/custom-hatch-pattern.js +0 -71
- package/dist/flatbuffers/duc/datum-bracket-style.d.ts +0 -5
- package/dist/flatbuffers/duc/datum-bracket-style.js +0 -8
- package/dist/flatbuffers/duc/datum-reference.d.ts +0 -17
- package/dist/flatbuffers/duc/datum-reference.js +0 -49
- package/dist/flatbuffers/duc/datum-target-type.d.ts +0 -6
- package/dist/flatbuffers/duc/datum-target-type.js +0 -9
- package/dist/flatbuffers/duc/decimal-separator.d.ts +0 -4
- package/dist/flatbuffers/duc/decimal-separator.js +0 -7
- package/dist/flatbuffers/duc/delta.d.ts +0 -22
- package/dist/flatbuffers/duc/delta.js +0 -75
- package/dist/flatbuffers/duc/dictionary-entry.d.ts +0 -17
- package/dist/flatbuffers/duc/dictionary-entry.js +0 -49
- package/dist/flatbuffers/duc/dimension-baseline-data.d.ts +0 -14
- package/dist/flatbuffers/duc/dimension-baseline-data.js +0 -40
- package/dist/flatbuffers/duc/dimension-bindings.d.ts +0 -17
- package/dist/flatbuffers/duc/dimension-bindings.js +0 -50
- package/dist/flatbuffers/duc/dimension-continue-data.d.ts +0 -14
- package/dist/flatbuffers/duc/dimension-continue-data.js +0 -40
- package/dist/flatbuffers/duc/dimension-definition-points.d.ts +0 -21
- package/dist/flatbuffers/duc/dimension-definition-points.js +0 -64
- package/dist/flatbuffers/duc/dimension-ext-line-style.d.ts +0 -18
- package/dist/flatbuffers/duc/dimension-ext-line-style.js +0 -57
- package/dist/flatbuffers/duc/dimension-fit-rule.d.ts +0 -6
- package/dist/flatbuffers/duc/dimension-fit-rule.js +0 -9
- package/dist/flatbuffers/duc/dimension-fit-style.d.ts +0 -19
- package/dist/flatbuffers/duc/dimension-fit-style.js +0 -58
- package/dist/flatbuffers/duc/dimension-line-style.d.ts +0 -16
- package/dist/flatbuffers/duc/dimension-line-style.js +0 -49
- package/dist/flatbuffers/duc/dimension-symbol-style.d.ts +0 -22
- package/dist/flatbuffers/duc/dimension-symbol-style.js +0 -72
- package/dist/flatbuffers/duc/dimension-text-placement.d.ts +0 -5
- package/dist/flatbuffers/duc/dimension-text-placement.js +0 -8
- package/dist/flatbuffers/duc/dimension-tolerance-style.d.ts +0 -24
- package/dist/flatbuffers/duc/dimension-tolerance-style.js +0 -71
- package/dist/flatbuffers/duc/dimension-type.d.ts +0 -15
- package/dist/flatbuffers/duc/dimension-type.js +0 -18
- package/dist/flatbuffers/duc/dimension-units-format.d.ts +0 -7
- package/dist/flatbuffers/duc/dimension-units-format.js +0 -10
- package/dist/flatbuffers/duc/dimension-validation-rules.d.ts +0 -25
- package/dist/flatbuffers/duc/dimension-validation-rules.js +0 -74
- package/dist/flatbuffers/duc/document-grid-align-items.d.ts +0 -5
- package/dist/flatbuffers/duc/document-grid-align-items.js +0 -8
- package/dist/flatbuffers/duc/document-grid-config.d.ts +0 -22
- package/dist/flatbuffers/duc/document-grid-config.js +0 -73
- package/dist/flatbuffers/duc/duc-arrow-element.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-arrow-element.js +0 -49
- package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-block-attribute-definition-entry.js +0 -44
- package/dist/flatbuffers/duc/duc-block-attribute-definition.d.ts +0 -22
- package/dist/flatbuffers/duc/duc-block-attribute-definition.js +0 -64
- package/dist/flatbuffers/duc/duc-block-collection-entry.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-block-collection-entry.js +0 -48
- package/dist/flatbuffers/duc/duc-block-collection.d.ts +0 -31
- package/dist/flatbuffers/duc/duc-block-collection.js +0 -97
- package/dist/flatbuffers/duc/duc-block-duplication-array.d.ts +0 -19
- package/dist/flatbuffers/duc/duc-block-duplication-array.js +0 -64
- package/dist/flatbuffers/duc/duc-block-instance-element.d.ts +0 -10
- package/dist/flatbuffers/duc/duc-block-instance-element.js +0 -28
- package/dist/flatbuffers/duc/duc-block-instance.d.ts +0 -32
- package/dist/flatbuffers/duc/duc-block-instance.js +0 -100
- package/dist/flatbuffers/duc/duc-block-metadata.d.ts +0 -26
- package/dist/flatbuffers/duc/duc-block-metadata.js +0 -90
- package/dist/flatbuffers/duc/duc-block.d.ts +0 -36
- package/dist/flatbuffers/duc/duc-block.js +0 -112
- package/dist/flatbuffers/duc/duc-common-style.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-common-style.js +0 -44
- package/dist/flatbuffers/duc/duc-dimension-element.d.ts +0 -45
- package/dist/flatbuffers/duc/duc-dimension-element.js +0 -120
- package/dist/flatbuffers/duc/duc-dimension-style.d.ts +0 -28
- package/dist/flatbuffers/duc/duc-dimension-style.js +0 -76
- package/dist/flatbuffers/duc/duc-doc-element.d.ts +0 -39
- package/dist/flatbuffers/duc/duc-doc-element.js +0 -110
- package/dist/flatbuffers/duc/duc-doc-style.d.ts +0 -19
- package/dist/flatbuffers/duc/duc-doc-style.js +0 -52
- package/dist/flatbuffers/duc/duc-element-base.d.ts +0 -100
- package/dist/flatbuffers/duc/duc-element-base.js +0 -315
- package/dist/flatbuffers/duc/duc-element-styles-base.d.ts +0 -30
- package/dist/flatbuffers/duc/duc-element-styles-base.js +0 -103
- package/dist/flatbuffers/duc/duc-ellipse-element.d.ts +0 -22
- package/dist/flatbuffers/duc/duc-ellipse-element.js +0 -73
- package/dist/flatbuffers/duc/duc-embeddable-element.d.ts +0 -14
- package/dist/flatbuffers/duc/duc-embeddable-element.js +0 -41
- package/dist/flatbuffers/duc/duc-external-file-data.d.ts +0 -27
- package/dist/flatbuffers/duc/duc-external-file-data.js +0 -92
- package/dist/flatbuffers/duc/duc-external-file-entry.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-external-file-entry.js +0 -44
- package/dist/flatbuffers/duc/duc-feature-control-frame-element.d.ts +0 -31
- package/dist/flatbuffers/duc/duc-feature-control-frame-element.js +0 -89
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.d.ts +0 -22
- package/dist/flatbuffers/duc/duc-feature-control-frame-style.js +0 -60
- package/dist/flatbuffers/duc/duc-frame-element.d.ts +0 -14
- package/dist/flatbuffers/duc/duc-frame-element.js +0 -41
- package/dist/flatbuffers/duc/duc-free-draw-element.d.ts +0 -52
- package/dist/flatbuffers/duc/duc-free-draw-element.js +0 -154
- package/dist/flatbuffers/duc/duc-free-draw-ends.d.ts +0 -18
- package/dist/flatbuffers/duc/duc-free-draw-ends.js +0 -56
- package/dist/flatbuffers/duc/duc-global-state.d.ts +0 -37
- package/dist/flatbuffers/duc/duc-global-state.js +0 -121
- package/dist/flatbuffers/duc/duc-group.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-group.js +0 -44
- package/dist/flatbuffers/duc/duc-hatch-style.d.ts +0 -28
- package/dist/flatbuffers/duc/duc-hatch-style.js +0 -79
- package/dist/flatbuffers/duc/duc-head.d.ts +0 -19
- package/dist/flatbuffers/duc/duc-head.js +0 -57
- package/dist/flatbuffers/duc/duc-image-element.d.ts +0 -35
- package/dist/flatbuffers/duc/duc-image-element.js +0 -91
- package/dist/flatbuffers/duc/duc-image-filter.d.ts +0 -15
- package/dist/flatbuffers/duc/duc-image-filter.js +0 -48
- package/dist/flatbuffers/duc/duc-layer-overrides.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-layer-overrides.js +0 -44
- package/dist/flatbuffers/duc/duc-layer.d.ts +0 -21
- package/dist/flatbuffers/duc/duc-layer.js +0 -59
- package/dist/flatbuffers/duc/duc-leader-element.d.ts +0 -22
- package/dist/flatbuffers/duc/duc-leader-element.js +0 -60
- package/dist/flatbuffers/duc/duc-leader-style.d.ts +0 -27
- package/dist/flatbuffers/duc/duc-leader-style.js +0 -79
- package/dist/flatbuffers/duc/duc-line-reference.d.ts +0 -15
- package/dist/flatbuffers/duc/duc-line-reference.js +0 -43
- package/dist/flatbuffers/duc/duc-line.d.ts +0 -15
- package/dist/flatbuffers/duc/duc-line.js +0 -43
- package/dist/flatbuffers/duc/duc-linear-element-base.d.ts +0 -38
- package/dist/flatbuffers/duc/duc-linear-element-base.js +0 -124
- package/dist/flatbuffers/duc/duc-linear-element.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-linear-element.js +0 -49
- package/dist/flatbuffers/duc/duc-local-state.d.ts +0 -68
- package/dist/flatbuffers/duc/duc-local-state.js +0 -206
- package/dist/flatbuffers/duc/duc-mermaid-element.d.ts +0 -23
- package/dist/flatbuffers/duc/duc-mermaid-element.js +0 -65
- package/dist/flatbuffers/duc/duc-model-element.d.ts +0 -26
- package/dist/flatbuffers/duc/duc-model-element.js +0 -79
- package/dist/flatbuffers/duc/duc-parametric-element.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-parametric-element.js +0 -44
- package/dist/flatbuffers/duc/duc-path.d.ts +0 -26
- package/dist/flatbuffers/duc/duc-path.js +0 -69
- package/dist/flatbuffers/duc/duc-pdf-element.d.ts +0 -19
- package/dist/flatbuffers/duc/duc-pdf-element.js +0 -51
- package/dist/flatbuffers/duc/duc-plot-element.d.ts +0 -19
- package/dist/flatbuffers/duc/duc-plot-element.js +0 -52
- package/dist/flatbuffers/duc/duc-plot-style.d.ts +0 -11
- package/dist/flatbuffers/duc/duc-plot-style.js +0 -32
- package/dist/flatbuffers/duc/duc-point-binding.d.ts +0 -26
- package/dist/flatbuffers/duc/duc-point-binding.js +0 -73
- package/dist/flatbuffers/duc/duc-point.d.ts +0 -18
- package/dist/flatbuffers/duc/duc-point.js +0 -57
- package/dist/flatbuffers/duc/duc-polygon-element.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-polygon-element.js +0 -49
- package/dist/flatbuffers/duc/duc-rectangle-element.d.ts +0 -14
- package/dist/flatbuffers/duc/duc-rectangle-element.js +0 -41
- package/dist/flatbuffers/duc/duc-region.d.ts +0 -19
- package/dist/flatbuffers/duc/duc-region.js +0 -51
- package/dist/flatbuffers/duc/duc-stack-base.d.ts +0 -27
- package/dist/flatbuffers/duc/duc-stack-base.js +0 -78
- package/dist/flatbuffers/duc/duc-stack-element-base.d.ts +0 -23
- package/dist/flatbuffers/duc/duc-stack-element-base.js +0 -65
- package/dist/flatbuffers/duc/duc-stack-like-styles.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-stack-like-styles.js +0 -48
- package/dist/flatbuffers/duc/duc-table-auto-size.d.ts +0 -15
- package/dist/flatbuffers/duc/duc-table-auto-size.js +0 -48
- package/dist/flatbuffers/duc/duc-table-cell-entry.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-table-cell-entry.js +0 -44
- package/dist/flatbuffers/duc/duc-table-cell-span.d.ts +0 -15
- package/dist/flatbuffers/duc/duc-table-cell-span.js +0 -48
- package/dist/flatbuffers/duc/duc-table-cell-style.d.ts +0 -22
- package/dist/flatbuffers/duc/duc-table-cell-style.js +0 -59
- package/dist/flatbuffers/duc/duc-table-cell.d.ts +0 -27
- package/dist/flatbuffers/duc/duc-table-cell.js +0 -72
- package/dist/flatbuffers/duc/duc-table-column-entry.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-table-column-entry.js +0 -44
- package/dist/flatbuffers/duc/duc-table-column.d.ts +0 -18
- package/dist/flatbuffers/duc/duc-table-column.js +0 -51
- package/dist/flatbuffers/duc/duc-table-element.d.ts +0 -51
- package/dist/flatbuffers/duc/duc-table-element.js +0 -167
- package/dist/flatbuffers/duc/duc-table-row-entry.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-table-row-entry.js +0 -44
- package/dist/flatbuffers/duc/duc-table-row.d.ts +0 -18
- package/dist/flatbuffers/duc/duc-table-row.js +0 -51
- package/dist/flatbuffers/duc/duc-table-style.d.ts +0 -20
- package/dist/flatbuffers/duc/duc-table-style.js +0 -57
- package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.d.ts +0 -14
- package/dist/flatbuffers/duc/duc-text-dynamic-dictionary-source.js +0 -40
- package/dist/flatbuffers/duc/duc-text-dynamic-element-source.d.ts +0 -17
- package/dist/flatbuffers/duc/duc-text-dynamic-element-source.js +0 -49
- package/dist/flatbuffers/duc/duc-text-dynamic-part.d.ts +0 -22
- package/dist/flatbuffers/duc/duc-text-dynamic-part.js +0 -58
- package/dist/flatbuffers/duc/duc-text-dynamic-source-data.d.ts +0 -9
- package/dist/flatbuffers/duc/duc-text-dynamic-source-data.js +0 -26
- package/dist/flatbuffers/duc/duc-text-dynamic-source.d.ts +0 -19
- package/dist/flatbuffers/duc/duc-text-dynamic-source.js +0 -58
- package/dist/flatbuffers/duc/duc-text-element.d.ts +0 -33
- package/dist/flatbuffers/duc/duc-text-element.js +0 -94
- package/dist/flatbuffers/duc/duc-text-style.d.ts +0 -41
- package/dist/flatbuffers/duc/duc-text-style.js +0 -120
- package/dist/flatbuffers/duc/duc-ucs.d.ts +0 -16
- package/dist/flatbuffers/duc/duc-ucs.js +0 -49
- package/dist/flatbuffers/duc/duc-view.d.ts +0 -24
- package/dist/flatbuffers/duc/duc-view.js +0 -71
- package/dist/flatbuffers/duc/duc-viewport-element.d.ts +0 -36
- package/dist/flatbuffers/duc/duc-viewport-element.js +0 -102
- package/dist/flatbuffers/duc/duc-viewport-style.d.ts +0 -13
- package/dist/flatbuffers/duc/duc-viewport-style.js +0 -40
- package/dist/flatbuffers/duc/duc-xray-element.d.ts +0 -23
- package/dist/flatbuffers/duc/duc-xray-element.js +0 -66
- package/dist/flatbuffers/duc/duc-xray-style.d.ts +0 -14
- package/dist/flatbuffers/duc/duc-xray-style.js +0 -40
- package/dist/flatbuffers/duc/dynamic-snap-settings.d.ts +0 -17
- package/dist/flatbuffers/duc/dynamic-snap-settings.js +0 -56
- package/dist/flatbuffers/duc/element-background.d.ts +0 -14
- package/dist/flatbuffers/duc/element-background.js +0 -41
- package/dist/flatbuffers/duc/element-content-base.d.ts +0 -29
- package/dist/flatbuffers/duc/element-content-base.js +0 -80
- package/dist/flatbuffers/duc/element-content-preference.d.ts +0 -8
- package/dist/flatbuffers/duc/element-content-preference.js +0 -11
- package/dist/flatbuffers/duc/element-stroke.d.ts +0 -24
- package/dist/flatbuffers/duc/element-stroke.js +0 -66
- package/dist/flatbuffers/duc/element-wrapper.d.ts +0 -16
- package/dist/flatbuffers/duc/element-wrapper.js +0 -49
- package/dist/flatbuffers/duc/element.d.ts +0 -51
- package/dist/flatbuffers/duc/element.js +0 -110
- package/dist/flatbuffers/duc/exported-data-state.d.ts +0 -102
- package/dist/flatbuffers/duc/exported-data-state.js +0 -341
- package/dist/flatbuffers/duc/fcfbetween-modifier.d.ts +0 -17
- package/dist/flatbuffers/duc/fcfbetween-modifier.js +0 -48
- package/dist/flatbuffers/duc/fcfdatum-definition.d.ts +0 -16
- package/dist/flatbuffers/duc/fcfdatum-definition.js +0 -43
- package/dist/flatbuffers/duc/fcfdatum-style.d.ts +0 -14
- package/dist/flatbuffers/duc/fcfdatum-style.js +0 -41
- package/dist/flatbuffers/duc/fcfframe-modifiers.d.ts +0 -22
- package/dist/flatbuffers/duc/fcfframe-modifiers.js +0 -65
- package/dist/flatbuffers/duc/fcflayout-style.d.ts +0 -17
- package/dist/flatbuffers/duc/fcflayout-style.js +0 -56
- package/dist/flatbuffers/duc/fcfprojected-zone-modifier.d.ts +0 -13
- package/dist/flatbuffers/duc/fcfprojected-zone-modifier.js +0 -40
- package/dist/flatbuffers/duc/fcfsegment-row.d.ts +0 -17
- package/dist/flatbuffers/duc/fcfsegment-row.js +0 -55
- package/dist/flatbuffers/duc/fcfsymbol-style.d.ts +0 -13
- package/dist/flatbuffers/duc/fcfsymbol-style.js +0 -40
- package/dist/flatbuffers/duc/feature-control-frame-segment.d.ts +0 -22
- package/dist/flatbuffers/duc/feature-control-frame-segment.js +0 -65
- package/dist/flatbuffers/duc/feature-modifier.d.ts +0 -18
- package/dist/flatbuffers/duc/feature-modifier.js +0 -21
- package/dist/flatbuffers/duc/gdt-symbol.d.ts +0 -22
- package/dist/flatbuffers/duc/gdt-symbol.js +0 -25
- package/dist/flatbuffers/duc/geometric-point.d.ts +0 -10
- package/dist/flatbuffers/duc/geometric-point.js +0 -27
- package/dist/flatbuffers/duc/grid-display-type.d.ts +0 -6
- package/dist/flatbuffers/duc/grid-display-type.js +0 -9
- package/dist/flatbuffers/duc/grid-settings.d.ts +0 -54
- package/dist/flatbuffers/duc/grid-settings.js +0 -165
- package/dist/flatbuffers/duc/grid-style.d.ts +0 -26
- package/dist/flatbuffers/duc/grid-style.js +0 -74
- package/dist/flatbuffers/duc/grid-type.d.ts +0 -7
- package/dist/flatbuffers/duc/grid-type.js +0 -10
- package/dist/flatbuffers/duc/handle-type.d.ts +0 -4
- package/dist/flatbuffers/duc/handle-type.js +0 -7
- package/dist/flatbuffers/duc/hatch-pattern-line.d.ts +0 -35
- package/dist/flatbuffers/duc/hatch-pattern-line.js +0 -93
- package/dist/flatbuffers/duc/hatch-style.d.ts +0 -5
- package/dist/flatbuffers/duc/hatch-style.js +0 -8
- package/dist/flatbuffers/duc/identified-common-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-common-style.js +0 -44
- package/dist/flatbuffers/duc/identified-dimension-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-dimension-style.js +0 -44
- package/dist/flatbuffers/duc/identified-doc-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-doc-style.js +0 -44
- package/dist/flatbuffers/duc/identified-fcfstyle.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-fcfstyle.js +0 -44
- package/dist/flatbuffers/duc/identified-grid-settings.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-grid-settings.js +0 -44
- package/dist/flatbuffers/duc/identified-hatch-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-hatch-style.js +0 -44
- package/dist/flatbuffers/duc/identified-leader-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-leader-style.js +0 -44
- package/dist/flatbuffers/duc/identified-snap-settings.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-snap-settings.js +0 -44
- package/dist/flatbuffers/duc/identified-stack-like-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-stack-like-style.js +0 -44
- package/dist/flatbuffers/duc/identified-table-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-table-style.js +0 -44
- package/dist/flatbuffers/duc/identified-text-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-text-style.js +0 -44
- package/dist/flatbuffers/duc/identified-ucs.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-ucs.js +0 -44
- package/dist/flatbuffers/duc/identified-view.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-view.js +0 -44
- package/dist/flatbuffers/duc/identified-viewport-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-viewport-style.js +0 -44
- package/dist/flatbuffers/duc/identified-xray-style.d.ts +0 -16
- package/dist/flatbuffers/duc/identified-xray-style.js +0 -44
- package/dist/flatbuffers/duc/identifier.d.ts +0 -20
- package/dist/flatbuffers/duc/identifier.js +0 -57
- package/dist/flatbuffers/duc/image-crop.d.ts +0 -23
- package/dist/flatbuffers/duc/image-crop.js +0 -80
- package/dist/flatbuffers/duc/image-status.d.ts +0 -5
- package/dist/flatbuffers/duc/image-status.js +0 -8
- package/dist/flatbuffers/duc/isometric-grid-settings.d.ts +0 -15
- package/dist/flatbuffers/duc/isometric-grid-settings.js +0 -48
- package/dist/flatbuffers/duc/jsonpatch-operation.d.ts +0 -23
- package/dist/flatbuffers/duc/jsonpatch-operation.js +0 -64
- package/dist/flatbuffers/duc/layer-snap-filters.d.ts +0 -23
- package/dist/flatbuffers/duc/layer-snap-filters.js +0 -76
- package/dist/flatbuffers/duc/layer-validation-rules.d.ts +0 -17
- package/dist/flatbuffers/duc/layer-validation-rules.js +0 -54
- package/dist/flatbuffers/duc/leader-block-content.d.ts +0 -25
- package/dist/flatbuffers/duc/leader-block-content.js +0 -85
- package/dist/flatbuffers/duc/leader-content-data.d.ts +0 -9
- package/dist/flatbuffers/duc/leader-content-data.js +0 -26
- package/dist/flatbuffers/duc/leader-content-type.d.ts +0 -4
- package/dist/flatbuffers/duc/leader-content-type.js +0 -7
- package/dist/flatbuffers/duc/leader-content.d.ts +0 -19
- package/dist/flatbuffers/duc/leader-content.js +0 -58
- package/dist/flatbuffers/duc/leader-text-block-content.d.ts +0 -14
- package/dist/flatbuffers/duc/leader-text-block-content.js +0 -40
- package/dist/flatbuffers/duc/line-head.d.ts +0 -17
- package/dist/flatbuffers/duc/line-head.js +0 -20
- package/dist/flatbuffers/duc/line-spacing-type.d.ts +0 -5
- package/dist/flatbuffers/duc/line-spacing-type.js +0 -8
- package/dist/flatbuffers/duc/line-spacing.d.ts +0 -16
- package/dist/flatbuffers/duc/line-spacing.js +0 -49
- package/dist/flatbuffers/duc/linear-unit-system.d.ts +0 -24
- package/dist/flatbuffers/duc/linear-unit-system.js +0 -75
- package/dist/flatbuffers/duc/margins.d.ts +0 -19
- package/dist/flatbuffers/duc/margins.js +0 -64
- package/dist/flatbuffers/duc/mark-ellipse-center.d.ts +0 -4
- package/dist/flatbuffers/duc/mark-ellipse-center.js +0 -7
- package/dist/flatbuffers/duc/material-condition.d.ts +0 -5
- package/dist/flatbuffers/duc/material-condition.js +0 -8
- package/dist/flatbuffers/duc/object-snap-mode.d.ts +0 -22
- package/dist/flatbuffers/duc/object-snap-mode.js +0 -25
- package/dist/flatbuffers/duc/paragraph-formatting.d.ts +0 -33
- package/dist/flatbuffers/duc/paragraph-formatting.js +0 -106
- package/dist/flatbuffers/duc/parametric-source-type.d.ts +0 -4
- package/dist/flatbuffers/duc/parametric-source-type.js +0 -7
- package/dist/flatbuffers/duc/parametric-source.d.ts +0 -20
- package/dist/flatbuffers/duc/parametric-source.js +0 -57
- package/dist/flatbuffers/duc/plot-layout.d.ts +0 -14
- package/dist/flatbuffers/duc/plot-layout.js +0 -41
- package/dist/flatbuffers/duc/point-binding-point.d.ts +0 -15
- package/dist/flatbuffers/duc/point-binding-point.js +0 -48
- package/dist/flatbuffers/duc/polar-grid-settings.d.ts +0 -17
- package/dist/flatbuffers/duc/polar-grid-settings.js +0 -56
- package/dist/flatbuffers/duc/polar-tracking-settings.d.ts +0 -29
- package/dist/flatbuffers/duc/polar-tracking-settings.js +0 -90
- package/dist/flatbuffers/duc/primary-units.d.ts +0 -16
- package/dist/flatbuffers/duc/primary-units.js +0 -44
- package/dist/flatbuffers/duc/pruning-level.d.ts +0 -5
- package/dist/flatbuffers/duc/pruning-level.js +0 -8
- package/dist/flatbuffers/duc/snap-marker-settings.d.ts +0 -23
- package/dist/flatbuffers/duc/snap-marker-settings.js +0 -79
- package/dist/flatbuffers/duc/snap-marker-shape.d.ts +0 -6
- package/dist/flatbuffers/duc/snap-marker-shape.js +0 -9
- package/dist/flatbuffers/duc/snap-marker-style-entry.d.ts +0 -16
- package/dist/flatbuffers/duc/snap-marker-style-entry.js +0 -43
- package/dist/flatbuffers/duc/snap-marker-style.d.ts +0 -17
- package/dist/flatbuffers/duc/snap-marker-style.js +0 -49
- package/dist/flatbuffers/duc/snap-mode.d.ts +0 -4
- package/dist/flatbuffers/duc/snap-mode.js +0 -7
- package/dist/flatbuffers/duc/snap-override-behavior.d.ts +0 -5
- package/dist/flatbuffers/duc/snap-override-behavior.js +0 -8
- package/dist/flatbuffers/duc/snap-override.d.ts +0 -17
- package/dist/flatbuffers/duc/snap-override.js +0 -49
- package/dist/flatbuffers/duc/snap-settings.d.ts +0 -75
- package/dist/flatbuffers/duc/snap-settings.js +0 -245
- package/dist/flatbuffers/duc/stack-format-properties.d.ts +0 -18
- package/dist/flatbuffers/duc/stack-format-properties.js +0 -57
- package/dist/flatbuffers/duc/stack-format.d.ts +0 -21
- package/dist/flatbuffers/duc/stack-format.js +0 -64
- package/dist/flatbuffers/duc/stacked-text-align.d.ts +0 -5
- package/dist/flatbuffers/duc/stacked-text-align.js +0 -8
- package/dist/flatbuffers/duc/standard-overrides.d.ts +0 -63
- package/dist/flatbuffers/duc/standard-overrides.js +0 -162
- package/dist/flatbuffers/duc/standard-styles.d.ts +0 -77
- package/dist/flatbuffers/duc/standard-styles.js +0 -285
- package/dist/flatbuffers/duc/standard-units.d.ts +0 -16
- package/dist/flatbuffers/duc/standard-units.js +0 -44
- package/dist/flatbuffers/duc/standard-validation.d.ts +0 -16
- package/dist/flatbuffers/duc/standard-validation.js +0 -44
- package/dist/flatbuffers/duc/standard-view-settings.d.ts +0 -35
- package/dist/flatbuffers/duc/standard-view-settings.js +0 -124
- package/dist/flatbuffers/duc/standard.d.ts +0 -33
- package/dist/flatbuffers/duc/standard.js +0 -90
- package/dist/flatbuffers/duc/string-value-entry.d.ts +0 -17
- package/dist/flatbuffers/duc/string-value-entry.js +0 -49
- package/dist/flatbuffers/duc/stroke-cap.d.ts +0 -5
- package/dist/flatbuffers/duc/stroke-cap.js +0 -8
- package/dist/flatbuffers/duc/stroke-join.d.ts +0 -5
- package/dist/flatbuffers/duc/stroke-join.js +0 -8
- package/dist/flatbuffers/duc/stroke-placement.d.ts +0 -5
- package/dist/flatbuffers/duc/stroke-placement.js +0 -8
- package/dist/flatbuffers/duc/stroke-preference.d.ts +0 -6
- package/dist/flatbuffers/duc/stroke-preference.js +0 -9
- package/dist/flatbuffers/duc/stroke-side-preference.d.ts +0 -8
- package/dist/flatbuffers/duc/stroke-side-preference.js +0 -11
- package/dist/flatbuffers/duc/stroke-sides.d.ts +0 -24
- package/dist/flatbuffers/duc/stroke-sides.js +0 -67
- package/dist/flatbuffers/duc/stroke-style.d.ts +0 -37
- package/dist/flatbuffers/duc/stroke-style.js +0 -111
- package/dist/flatbuffers/duc/stroke-width.d.ts +0 -5
- package/dist/flatbuffers/duc/stroke-width.js +0 -8
- package/dist/flatbuffers/duc/table-cell-alignment.d.ts +0 -11
- package/dist/flatbuffers/duc/table-cell-alignment.js +0 -14
- package/dist/flatbuffers/duc/table-flow-direction.d.ts +0 -4
- package/dist/flatbuffers/duc/table-flow-direction.js +0 -7
- package/dist/flatbuffers/duc/text-align.d.ts +0 -5
- package/dist/flatbuffers/duc/text-align.js +0 -8
- package/dist/flatbuffers/duc/text-column.d.ts +0 -15
- package/dist/flatbuffers/duc/text-column.js +0 -48
- package/dist/flatbuffers/duc/text-field-source-property.d.ts +0 -13
- package/dist/flatbuffers/duc/text-field-source-property.js +0 -16
- package/dist/flatbuffers/duc/text-field-source-type.d.ts +0 -4
- package/dist/flatbuffers/duc/text-field-source-type.js +0 -7
- package/dist/flatbuffers/duc/text-flow-direction.d.ts +0 -6
- package/dist/flatbuffers/duc/text-flow-direction.js +0 -9
- package/dist/flatbuffers/duc/tiling-properties.d.ts +0 -21
- package/dist/flatbuffers/duc/tiling-properties.js +0 -75
- package/dist/flatbuffers/duc/tolerance-clause.d.ts +0 -27
- package/dist/flatbuffers/duc/tolerance-clause.js +0 -84
- package/dist/flatbuffers/duc/tolerance-display.d.ts +0 -7
- package/dist/flatbuffers/duc/tolerance-display.js +0 -10
- package/dist/flatbuffers/duc/tolerance-type.d.ts +0 -5
- package/dist/flatbuffers/duc/tolerance-type.js +0 -8
- package/dist/flatbuffers/duc/tolerance-zone-type.d.ts +0 -7
- package/dist/flatbuffers/duc/tolerance-zone-type.js +0 -10
- package/dist/flatbuffers/duc/tracking-line-style.d.ts +0 -26
- package/dist/flatbuffers/duc/tracking-line-style.js +0 -74
- package/dist/flatbuffers/duc/unit-precision.d.ts +0 -19
- package/dist/flatbuffers/duc/unit-precision.js +0 -64
- package/dist/flatbuffers/duc/unit-system-base.d.ts +0 -20
- package/dist/flatbuffers/duc/unit-system-base.js +0 -65
- package/dist/flatbuffers/duc/unit-system.d.ts +0 -4
- package/dist/flatbuffers/duc/unit-system.js +0 -7
- package/dist/flatbuffers/duc/version-base.d.ts +0 -27
- package/dist/flatbuffers/duc/version-base.js +0 -80
- package/dist/flatbuffers/duc/version-graph-metadata.d.ts +0 -15
- package/dist/flatbuffers/duc/version-graph-metadata.js +0 -48
- package/dist/flatbuffers/duc/version-graph.d.ts +0 -31
- package/dist/flatbuffers/duc/version-graph.js +0 -94
- package/dist/flatbuffers/duc/vertical-align.d.ts +0 -5
- package/dist/flatbuffers/duc/vertical-align.js +0 -8
- package/dist/flatbuffers/duc/viewport-shade-plot.d.ts +0 -6
- package/dist/flatbuffers/duc/viewport-shade-plot.js +0 -9
- package/dist/flatbuffers/duc/youtube-states.d.ts +0 -8
- package/dist/flatbuffers/duc/youtube-states.js +0 -11
- package/dist/flatbuffers/duc.d.ts +0 -234
- package/dist/flatbuffers/duc.js +0 -236
- package/dist/restore/restoreStandards.d.ts +0 -8
- package/dist/restore/restoreStandards.js +0 -224
- package/dist/technical/standards.d.ts +0 -124
- package/dist/technical/standards.js +0 -10
- package/dist/utils/elements/viewportElement.d.ts +0 -6
- package/dist/utils/elements/viewportElement.js +0 -9
- package/dist/utils/state/grid.d.ts +0 -7
- package/dist/utils/state/grid.js +0 -25
|
@@ -9,13 +9,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { getUpdatedTimestamp
|
|
13
|
-
import {
|
|
12
|
+
import { getUpdatedTimestamp } from "..";
|
|
13
|
+
import { IMAGE_STATUS, LINE_SPACING_TYPE, } from "../../enums";
|
|
14
14
|
import { getPrecisionValueFromRaw } from "../../technical/scopes";
|
|
15
15
|
import { DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN } from "../constants";
|
|
16
16
|
import { randomId, randomInteger } from "../math/random";
|
|
17
17
|
import { normalizeText } from "../normalize";
|
|
18
|
-
import { getDefaultStackProperties
|
|
18
|
+
import { getDefaultStackProperties } from "./";
|
|
19
19
|
import { getFontString, getTextElementPositionOffsets, measureText, } from "./textElement";
|
|
20
20
|
export const newElementWith = (element, updates,
|
|
21
21
|
/** pass `true` to always regenerate */
|
|
@@ -39,7 +39,7 @@ force = false) => {
|
|
|
39
39
|
};
|
|
40
40
|
const _newElementBase = (type, currentScope, _a) => {
|
|
41
41
|
var _b, _c;
|
|
42
|
-
var { x, y, scope = currentScope, zIndex, index = DEFAULT_ELEMENT_PROPS.index, label, isVisible = DEFAULT_ELEMENT_PROPS.isVisible, isPlot = DEFAULT_ELEMENT_PROPS.isPlot,
|
|
42
|
+
var { x, y, scope = currentScope, zIndex, index = DEFAULT_ELEMENT_PROPS.index, label, isVisible = DEFAULT_ELEMENT_PROPS.isVisible, isPlot = DEFAULT_ELEMENT_PROPS.isPlot, stroke = [DEFAULT_ELEMENT_PROPS.stroke], background = [DEFAULT_ELEMENT_PROPS.background], opacity = DEFAULT_ELEMENT_PROPS.opacity, width = DEFAULT_ELEMENT_PROPS.width, height = DEFAULT_ELEMENT_PROPS.height, angle = DEFAULT_ELEMENT_PROPS.angle, groupIds = DEFAULT_ELEMENT_PROPS.groupIds, blockIds = [], instanceId = null, regionIds = [], frameId = DEFAULT_ELEMENT_PROPS.frameId, layerId = null, roundness = DEFAULT_ELEMENT_PROPS.roundness, boundElements = DEFAULT_ELEMENT_PROPS.boundElements, link = DEFAULT_ELEMENT_PROPS.link, locked = DEFAULT_ELEMENT_PROPS.locked, description = null } = _a, rest = __rest(_a, ["x", "y", "scope", "zIndex", "index", "label", "isVisible", "isPlot", "stroke", "background", "opacity", "width", "height", "angle", "groupIds", "blockIds", "instanceId", "regionIds", "frameId", "layerId", "roundness", "boundElements", "link", "locked", "description"]);
|
|
43
43
|
// assign type to guard against excess properties
|
|
44
44
|
const element = {
|
|
45
45
|
id: rest.id || randomId(),
|
|
@@ -73,7 +73,6 @@ const _newElementBase = (type, currentScope, _a) => {
|
|
|
73
73
|
description,
|
|
74
74
|
customData: rest.customData,
|
|
75
75
|
isPlot,
|
|
76
|
-
isAnnotative,
|
|
77
76
|
regionIds,
|
|
78
77
|
layerId,
|
|
79
78
|
};
|
|
@@ -83,8 +82,8 @@ export const newElement = (currentScope, opts) => _newElementBase(opts.type, cur
|
|
|
83
82
|
export const newEmbeddableElement = (currentScope, opts) => {
|
|
84
83
|
return Object.assign(Object.assign({}, opts), _newElementBase(opts.type, currentScope, opts));
|
|
85
84
|
};
|
|
86
|
-
export const newFrameElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true
|
|
87
|
-
export const newPlotElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true,
|
|
85
|
+
export const newFrameElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true }), _newElementBase("frame", currentScope, opts)), { type: "frame" }));
|
|
86
|
+
export const newPlotElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { clip: false, labelVisible: true, layout: {
|
|
88
87
|
margins: {
|
|
89
88
|
top: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
90
89
|
right: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
@@ -92,20 +91,6 @@ export const newPlotElement = (currentScope, opts) => (Object.assign(Object.assi
|
|
|
92
91
|
left: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
93
92
|
}
|
|
94
93
|
} }), _newElementBase("plot", currentScope, opts)), { type: "plot" }));
|
|
95
|
-
export const newViewportElement = (currentScope, opts) => {
|
|
96
|
-
var _a, _b, _c;
|
|
97
|
-
return (Object.assign(Object.assign(Object.assign(Object.assign({}, getDefaultStackProperties()), { points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, standardOverride: null, view: {
|
|
98
|
-
scrollX: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
99
|
-
scrollY: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
100
|
-
zoom: getZoom((_a = opts.zoom) !== null && _a !== void 0 ? _a : 1, (_b = opts.mainScope) !== null && _b !== void 0 ? _b : currentScope, (_c = opts.scopeExponentThreshold) !== null && _c !== void 0 ? _c : 2),
|
|
101
|
-
twistAngle: 0,
|
|
102
|
-
centerPoint: {
|
|
103
|
-
x: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
104
|
-
y: getPrecisionValueFromRaw(0, currentScope, currentScope),
|
|
105
|
-
},
|
|
106
|
-
scope: currentScope,
|
|
107
|
-
}, scale: 1, shadePlot: VIEWPORT_SHADE_PLOT.AS_DISPLAYED, frozenGroupIds: [], scaleIndicatorVisible: true }), _newElementBase("viewport", currentScope, opts)), { type: "viewport" }));
|
|
108
|
-
};
|
|
109
94
|
export const newEllipseElement = (currentScope, opts) => {
|
|
110
95
|
return Object.assign(Object.assign({}, _newElementBase(opts.type, currentScope, opts)), { ratio: opts.ratio || DEFAULT_ELLIPSE_ELEMENT.ratio, startAngle: opts.startAngle || DEFAULT_ELLIPSE_ELEMENT.startAngle, endAngle: opts.endAngle || DEFAULT_ELLIPSE_ELEMENT.endAngle, showAuxCrosshair: opts.showAuxCrosshair || DEFAULT_ELLIPSE_ELEMENT.showAuxCrosshair });
|
|
111
96
|
};
|
|
@@ -123,15 +108,24 @@ export const newTextElement = (currentScope, opts) => {
|
|
|
123
108
|
const textAlign = opts.textAlign || DEFAULT_TEXT_ALIGN;
|
|
124
109
|
const verticalAlign = opts.verticalAlign || DEFAULT_VERTICAL_ALIGN;
|
|
125
110
|
const offsets = getTextElementPositionOffsets({ textAlign, verticalAlign }, metrics);
|
|
111
|
+
// Minimum dimensions: at least 1px wide, at least one line high (NaN-safe)
|
|
112
|
+
const rawMinLineHeight = fontSize.value * lineHeight;
|
|
113
|
+
const minLineHeight = (Number.isFinite(rawMinLineHeight) && rawMinLineHeight > 0)
|
|
114
|
+
? rawMinLineHeight
|
|
115
|
+
: DEFAULT_FONT_SIZE * lineHeight;
|
|
116
|
+
const finalWidth = (Number.isFinite(metrics.width) && metrics.width > 0) ? metrics.width : 1;
|
|
117
|
+
const finalHeight = (Number.isFinite(metrics.height) && metrics.height > 0)
|
|
118
|
+
? Math.max(metrics.height, minLineHeight)
|
|
119
|
+
: minLineHeight;
|
|
126
120
|
const x = getPrecisionValueFromRaw(opts.x.value - offsets.x, scope, currentScope);
|
|
127
121
|
const y = getPrecisionValueFromRaw(opts.y.value - offsets.y, scope, currentScope);
|
|
128
122
|
return Object.assign(Object.assign({}, _newElementBase("text", currentScope, Object.assign(Object.assign({}, opts), { x, y }))), { type: "text", text,
|
|
129
123
|
fontSize,
|
|
130
124
|
fontFamily,
|
|
131
125
|
textAlign,
|
|
132
|
-
verticalAlign, width: getPrecisionValueFromRaw(
|
|
126
|
+
verticalAlign, width: getPrecisionValueFromRaw(finalWidth, scope, currentScope), height: getPrecisionValueFromRaw(finalHeight, scope, currentScope), containerId: opts.containerId || null, originalText: (_b = opts.originalText) !== null && _b !== void 0 ? _b : text, autoResize: (_c = opts.autoResize) !== null && _c !== void 0 ? _c : true, lineHeight,
|
|
133
127
|
// DucTextStyle properties
|
|
134
|
-
isLtr: (_d = opts.isLtr) !== null && _d !== void 0 ? _d : true, bigFontFamily: opts.bigFontFamily || "sans-serif", lineSpacing: opts.lineSpacing || { type: LINE_SPACING_TYPE.MULTIPLE, value: lineHeight }, obliqueAngle: opts.obliqueAngle || 0,
|
|
128
|
+
isLtr: (_d = opts.isLtr) !== null && _d !== void 0 ? _d : true, bigFontFamily: opts.bigFontFamily || "sans-serif", lineSpacing: opts.lineSpacing || { type: LINE_SPACING_TYPE.MULTIPLE, value: lineHeight }, obliqueAngle: opts.obliqueAngle || 0, widthFactor: opts.widthFactor || 1, isUpsideDown: (_e = opts.isUpsideDown) !== null && _e !== void 0 ? _e : false, isBackwards: (_f = opts.isBackwards) !== null && _f !== void 0 ? _f : false });
|
|
135
129
|
};
|
|
136
130
|
export const newFreeDrawElement = (currentScope, opts) => {
|
|
137
131
|
var _a, _b, _c, _d;
|
|
@@ -150,36 +144,22 @@ export const newImageElement = (currentScope, opts) => {
|
|
|
150
144
|
var _a, _b, _c;
|
|
151
145
|
return (Object.assign(Object.assign({}, _newElementBase("image", currentScope, 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 }));
|
|
152
146
|
};
|
|
153
|
-
export const newTableElement = (currentScope, opts) =>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return (Object.assign(Object.assign({}, _newElementBase("doc", currentScope, opts)), { type: "doc", text: opts.text || "", dynamic: opts.dynamic || [], flowDirection: opts.flowDirection || TEXT_FLOW_DIRECTION.TOP_TO_BOTTOM, columns: opts.columns || { type: COLUMN_TYPE.NO_COLUMNS, definitions: [], autoHeight: true }, autoResize: (_a = opts.autoResize) !== null && _a !== void 0 ? _a : true, fileId: null, gridConfig: { columns: 1, gapX: 0, gapY: 0, alignItems: 'start', firstPageAlone: false },
|
|
157
|
-
// DucDocStyle properties
|
|
158
|
-
isLtr: (_b = opts.isLtr) !== null && _b !== void 0 ? _b : true, fontFamily: opts.fontFamily || DEFAULT_FONT_FAMILY, bigFontFamily: opts.bigFontFamily || "sans-serif", textAlign: opts.textAlign || DEFAULT_TEXT_ALIGN, verticalAlign: opts.verticalAlign || DEFAULT_VERTICAL_ALIGN, lineHeight: opts.lineHeight || 1.2, lineSpacing: opts.lineSpacing || { type: LINE_SPACING_TYPE.MULTIPLE, value: 1.2 }, obliqueAngle: opts.obliqueAngle || 0, fontSize: opts.fontSize || getPrecisionValueFromRaw(DEFAULT_FONT_SIZE, currentScope, currentScope), paperTextHeight: opts.paperTextHeight, widthFactor: opts.widthFactor || 1, isUpsideDown: (_c = opts.isUpsideDown) !== null && _c !== void 0 ? _c : false, isBackwards: (_d = opts.isBackwards) !== null && _d !== void 0 ? _d : false, paragraph: opts.paragraph || { firstLineIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), hangingIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), leftIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), rightIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceBefore: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceAfter: getPrecisionValueFromRaw(0, currentScope, currentScope), tabStops: [] }, stackFormat: opts.stackFormat || { autoStack: false, stackChars: [], properties: { upperScale: 0.7, lowerScale: 0.7, alignment: STACKED_TEXT_ALIGN.CENTER } } }));
|
|
159
|
-
};
|
|
160
|
-
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null, gridConfig: { columns: 1, gapX: 0, gapY: 0, alignItems: 'start', firstPageAlone: false } }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
|
|
161
|
-
export const newMermaidElement = (currentScope, opts) => (Object.assign(Object.assign({ source: "", theme: undefined, svgPath: null }, _newElementBase("mermaid", currentScope, opts)), { type: "mermaid" }));
|
|
162
|
-
export const newXRayElement = (currentScope, opts) => (Object.assign(Object.assign({ origin: { x: getPrecisionValueFromRaw(0, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, direction: { x: getPrecisionValueFromRaw(1, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, startFromOrigin: false, color: '#FF00FF' }, _newElementBase("xray", currentScope, opts)), { type: "xray" }));
|
|
163
|
-
export const newLeaderElement = (currentScope, opts) => {
|
|
164
|
-
var _a, _b;
|
|
165
|
-
return Object.assign(Object.assign({ points: [], lines: [], pathOverrides: [], lastCommittedPoint: null, startBinding: null, endBinding: null, headsOverride: undefined, dogleg: getPrecisionValueFromRaw(10, currentScope, currentScope), textStyle: opts.textStyle || getDefaultTextStyle(currentScope), textAttachment: opts.textAttachment || VERTICAL_ALIGN.TOP, blockAttachment: opts.blockAttachment || BLOCK_ATTACHMENT.CENTER_EXTENTS, leaderContent: (_a = opts.leaderContent) !== null && _a !== void 0 ? _a : null, contentAnchor: (_b = opts.contentAnchor) !== null && _b !== void 0 ? _b : {
|
|
166
|
-
x: 0,
|
|
167
|
-
y: 0,
|
|
168
|
-
} }, _newElementBase("leader", currentScope, opts)), { type: "leader" });
|
|
169
|
-
};
|
|
170
|
-
export const newDimensionElement = (currentScope, opts) => (Object.assign(Object.assign({}, _newElementBase("dimension", currentScope, opts)), { type: 'dimension' }));
|
|
171
|
-
export const newFeatureControlFrameElement = (currentScope, opts) => {
|
|
172
|
-
return Object.assign(Object.assign({ rows: [], leaderElementId: null, textStyle: getDefaultTextStyle(currentScope), layout: {
|
|
173
|
-
padding: getPrecisionValueFromRaw(4, currentScope, currentScope),
|
|
174
|
-
segmentSpacing: getPrecisionValueFromRaw(4, currentScope, currentScope),
|
|
175
|
-
rowSpacing: getPrecisionValueFromRaw(2, currentScope, currentScope),
|
|
176
|
-
}, symbols: {
|
|
177
|
-
scale: 1,
|
|
178
|
-
}, datumStyle: {
|
|
179
|
-
bracketStyle: DATUM_BRACKET_STYLE.SQUARE
|
|
180
|
-
} }, _newElementBase("featurecontrolframe", currentScope, opts)), { type: "featurecontrolframe" });
|
|
147
|
+
export const newTableElement = (currentScope, opts) => {
|
|
148
|
+
var _a;
|
|
149
|
+
return (Object.assign(Object.assign({}, _newElementBase("table", currentScope, opts)), { fileId: (_a = opts.fileId) !== null && _a !== void 0 ? _a : null, type: "table" }));
|
|
181
150
|
};
|
|
182
|
-
export const
|
|
151
|
+
export const newDocElement = (currentScope, opts) => {
|
|
152
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
153
|
+
return (Object.assign(Object.assign({}, _newElementBase("doc", currentScope, opts)), { type: "doc", text: opts.text || "", fileId: (_a = opts.fileId) !== null && _a !== void 0 ? _a : null, gridConfig: {
|
|
154
|
+
columns: (_c = (_b = opts.gridConfig) === null || _b === void 0 ? void 0 : _b.columns) !== null && _c !== void 0 ? _c : 1,
|
|
155
|
+
gapX: (_e = (_d = opts.gridConfig) === null || _d === void 0 ? void 0 : _d.gapX) !== null && _e !== void 0 ? _e : 0,
|
|
156
|
+
gapY: (_g = (_f = opts.gridConfig) === null || _f === void 0 ? void 0 : _f.gapY) !== null && _g !== void 0 ? _g : 0,
|
|
157
|
+
firstPageAlone: (_j = (_h = opts.gridConfig) === null || _h === void 0 ? void 0 : _h.firstPageAlone) !== null && _j !== void 0 ? _j : false,
|
|
158
|
+
scale: (_l = (_k = opts.gridConfig) === null || _k === void 0 ? void 0 : _k.scale) !== null && _l !== void 0 ? _l : 1,
|
|
159
|
+
} }));
|
|
160
|
+
};
|
|
161
|
+
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null, gridConfig: { columns: 1, gapX: 0, gapY: 0, firstPageAlone: false, scale: 1 } }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
|
|
162
|
+
export const newModelElement = (currentScope, opts) => (Object.assign(Object.assign({ modelType: null, code: null, svgPath: null, fileIds: [], viewerState: null }, _newElementBase("model", currentScope, opts)), { type: 'model' }));
|
|
183
163
|
// Simplified deep clone for the purpose of cloning DucElement.
|
|
184
164
|
//
|
|
185
165
|
// Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { SupportedMeasures } from "../../technical/scopes";
|
|
1
2
|
import { DucLocalState, RawValue, Scope, ScopedValue } from "../../types";
|
|
2
3
|
import { DucElement, DucElementType, DucTextContainer, DucTextElement, DucTextElementWithContainer, ElementsMap, FontFamilyValues, FontString, NonDeletedDucElement } from "../../types/elements";
|
|
3
4
|
import { GeometricPoint } from "../../types/geometryTypes";
|
|
4
5
|
import { ExtractSetType } from "../../types/utility-types";
|
|
5
6
|
import { getBoundTextElementPosition } from "./linearElement";
|
|
6
|
-
import { SupportedMeasures } from "../../technical/scopes";
|
|
7
7
|
export declare const computeBoundTextPosition: (container: DucElement, boundTextElement: DucTextElementWithContainer, elementsMap: ElementsMap, currentScope: SupportedMeasures) => {
|
|
8
8
|
x: ScopedValue;
|
|
9
9
|
y: ScopedValue;
|
|
@@ -49,12 +49,12 @@ export declare const getMinTextElementWidth: (font: FontString, lineHeight: DucT
|
|
|
49
49
|
/** retrieves text from text elements and concatenates to a single string */
|
|
50
50
|
export declare const getTextFromElements: (elements: readonly DucElement[], separator?: string) => string;
|
|
51
51
|
export declare const getFontFamilyString: ({ fontFamily, }: {
|
|
52
|
-
fontFamily: FontFamilyValues;
|
|
52
|
+
fontFamily: FontFamilyValues | string;
|
|
53
53
|
}) => string;
|
|
54
54
|
/** returns fontSize+fontFamily string for assignment to DOM elements */
|
|
55
55
|
export declare const getFontString: ({ fontSize, fontFamily, }: {
|
|
56
56
|
fontSize: DucTextElement["fontSize"];
|
|
57
|
-
fontFamily: FontFamilyValues;
|
|
57
|
+
fontFamily: FontFamilyValues | string;
|
|
58
58
|
}) => FontString;
|
|
59
59
|
/** computes element x/y offset based on textAlign/verticalAlign */
|
|
60
60
|
export declare const getTextElementPositionOffsets: (opts: {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { TEXT_ALIGN, VERTICAL_ALIGN } from "../../
|
|
1
|
+
import { TEXT_ALIGN, VERTICAL_ALIGN } from "../../enums";
|
|
2
|
+
import { getPrecisionValueFromRaw, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
|
|
2
3
|
import { isArrowElement, isBoundToContainer, isTextElement } from "../../types/elements/typeChecks";
|
|
3
4
|
import { getContainerElement, getElementAbsoluteCoords, getResizedElementAbsoluteCoords } from "../bounds";
|
|
4
|
-
import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE,
|
|
5
|
-
import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "./linearElement";
|
|
5
|
+
import { ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO, ARROW_LABEL_WIDTH_FRACTION, BOUND_TEXT_PADDING, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, LEGACY_FONT_ID_TO_NAME, WINDOWS_EMOJI_FALLBACK_FONT } from "../constants";
|
|
6
6
|
import { adjustXYWithRotation } from "../math";
|
|
7
7
|
import { normalizeText } from "../normalize";
|
|
8
|
-
import {
|
|
8
|
+
import { getBoundTextElementPosition, getPointGlobalCoordinates, getPointsGlobalCoordinates, getSegmentMidPoint } from "./linearElement";
|
|
9
9
|
export const computeBoundTextPosition = (container, boundTextElement, elementsMap, currentScope) => {
|
|
10
10
|
if (isArrowElement(container)) {
|
|
11
11
|
const coords = getBoundTextElementPosition(container, boundTextElement, elementsMap, currentScope);
|
|
@@ -54,10 +54,19 @@ export const measureText = (text, font, lineHeight, currentScope) => {
|
|
|
54
54
|
// lines would be stripped from computation
|
|
55
55
|
.map((x) => x || " ")
|
|
56
56
|
.join("\n");
|
|
57
|
-
const
|
|
57
|
+
const parsedFontSize = parseFloat(font);
|
|
58
|
+
// Guard: if font string produced an unparseable size (NaN) or zero,
|
|
59
|
+
// fall back to DEFAULT_FONT_SIZE so measurements are never degenerate.
|
|
60
|
+
const safeFontSize = (Number.isFinite(parsedFontSize) && parsedFontSize > 0)
|
|
61
|
+
? parsedFontSize
|
|
62
|
+
: DEFAULT_FONT_SIZE;
|
|
63
|
+
const fontSize = getPrecisionValueFromRaw(safeFontSize, currentScope, currentScope);
|
|
58
64
|
const height = getTextHeight(text, fontSize, lineHeight);
|
|
59
65
|
const width = getTextWidth(text, font);
|
|
60
|
-
return
|
|
66
|
+
// Defensive: ensure we never return 0 or NaN dimensions
|
|
67
|
+
const safeWidth = (Number.isFinite(width) && width > 0) ? width : 1;
|
|
68
|
+
const safeHeight = (Number.isFinite(height) && height > 0) ? height : (safeFontSize * lineHeight);
|
|
69
|
+
return { width: safeWidth, height: safeHeight };
|
|
61
70
|
};
|
|
62
71
|
/**
|
|
63
72
|
* We calculate the line height from the font size and the unitless line height,
|
|
@@ -104,15 +113,15 @@ const getLineWidth = (text, font, forceAdvanceWidth, isTestEnv) => {
|
|
|
104
113
|
// fallback to advance width if the actual width is zero, i.e. on text editing start
|
|
105
114
|
// or when actual width does not respect whitespace chars, i.e. spaces
|
|
106
115
|
// otherwise actual width should always be bigger
|
|
107
|
-
return Math.max(actualWidth, advanceWidth);
|
|
116
|
+
return Math.ceil(Math.max(actualWidth, advanceWidth));
|
|
108
117
|
}
|
|
109
118
|
// since in test env the canvas measureText algo
|
|
110
119
|
// doesn't measure text and instead just returns number of
|
|
111
120
|
// characters hence we assume that each letteris 10px
|
|
112
121
|
if (isTestEnv) {
|
|
113
|
-
return advanceWidth * 10;
|
|
122
|
+
return Math.ceil(advanceWidth * 10);
|
|
114
123
|
}
|
|
115
|
-
return advanceWidth;
|
|
124
|
+
return Math.ceil(advanceWidth);
|
|
116
125
|
};
|
|
117
126
|
export const getTextWidth = (text, font, forceAdvanceWidth) => {
|
|
118
127
|
const lines = splitIntoLines(text);
|
|
@@ -470,14 +479,20 @@ export const getTextFromElements = (elements, separator = "\n\n") => {
|
|
|
470
479
|
return text;
|
|
471
480
|
};
|
|
472
481
|
export const getFontFamilyString = ({ fontFamily, }) => {
|
|
473
|
-
// Handle
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (
|
|
477
|
-
return `${
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
482
|
+
// Handle legacy numeric font IDs from old files
|
|
483
|
+
if (typeof fontFamily === "number") {
|
|
484
|
+
const name = LEGACY_FONT_ID_TO_NAME[fontFamily];
|
|
485
|
+
if (name)
|
|
486
|
+
return `${name}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
|
|
487
|
+
return WINDOWS_EMOJI_FALLBACK_FONT;
|
|
488
|
+
}
|
|
489
|
+
// Handle stringified numeric IDs (e.g. "10")
|
|
490
|
+
const parsed = Number(fontFamily);
|
|
491
|
+
if (!Number.isNaN(parsed) && LEGACY_FONT_ID_TO_NAME[parsed]) {
|
|
492
|
+
return `${LEGACY_FONT_ID_TO_NAME[parsed]}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
|
|
493
|
+
}
|
|
494
|
+
// New path: fontFamily is already a string name
|
|
495
|
+
return `${fontFamily}, ${WINDOWS_EMOJI_FALLBACK_FONT}`;
|
|
481
496
|
};
|
|
482
497
|
/** returns fontSize+fontFamily string for assignment to DOM elements */
|
|
483
498
|
export const getFontString = ({ fontSize, fontFamily, }) => {
|
|
@@ -504,6 +519,18 @@ export const refreshTextDimensions = (textElement, container, elementsMap, curre
|
|
|
504
519
|
: textElement.width.scoped);
|
|
505
520
|
}
|
|
506
521
|
const dimensions = getAdjustedDimensions(textElement, elementsMap, text, currentScope);
|
|
522
|
+
// Defensive minimums — ensure height is always at least one line.
|
|
523
|
+
// Use negated >= to also catch NaN (NaN < x is always false).
|
|
524
|
+
const rawMinLineHeight = textElement.fontSize.value * textElement.lineHeight;
|
|
525
|
+
const minLineHeight = (Number.isFinite(rawMinLineHeight) && rawMinLineHeight > 0)
|
|
526
|
+
? rawMinLineHeight
|
|
527
|
+
: DEFAULT_FONT_SIZE * textElement.lineHeight;
|
|
528
|
+
if (!(dimensions.height >= minLineHeight)) {
|
|
529
|
+
dimensions.height = minLineHeight;
|
|
530
|
+
}
|
|
531
|
+
if (!(dimensions.width > 0)) {
|
|
532
|
+
dimensions.width = (textElement.autoResize ? 1 : textElement.width.value);
|
|
533
|
+
}
|
|
507
534
|
return Object.assign({ text }, dimensions);
|
|
508
535
|
};
|
|
509
536
|
export const splitIntoLines = (text) => {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export * from "./geometry";
|
|
2
|
-
export * from "./bbox";
|
|
3
1
|
export * from "./algebra";
|
|
2
|
+
export * from "./bbox";
|
|
3
|
+
export * from "./geometry";
|
|
4
4
|
export * from "./random";
|
|
5
|
-
import
|
|
5
|
+
import { SupportedMeasures } from "../../technical/scopes";
|
|
6
|
+
import type { Zoom } from "../../types";
|
|
6
7
|
import { Scope, ScopedValue } from "../../types";
|
|
7
8
|
import type { DucElement, DucLine, DucLinearElement, DucLinearLikeElement, DucPoint, NonDeleted } from "../../types/elements";
|
|
8
9
|
import type { Bounds, GeometricPoint, GeometricVector, Percentage, Radian } from "../../types/geometryTypes";
|
|
9
10
|
import { Heading } from "../../types/geometryTypes";
|
|
10
|
-
|
|
11
|
+
export type NullableGridSize = number | null;
|
|
11
12
|
export declare const getRadianFromDegrees: (degrees: number) => Radian;
|
|
12
13
|
export declare const getDegreesFromRadian: (radian: Radian) => number;
|
|
13
14
|
export declare const getPercentageValueFromPercentage: (value: number) => Percentage;
|
package/dist/utils/math/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./geometry";
|
|
2
|
-
export * from "./bbox";
|
|
3
1
|
export * from "./algebra";
|
|
2
|
+
export * from "./bbox";
|
|
3
|
+
export * from "./geometry";
|
|
4
4
|
export * from "./random";
|
|
5
|
+
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
|
|
5
6
|
import { LINE_CONFIRM_THRESHOLD } from "../constants";
|
|
6
7
|
import { pointFrom } from "./geometry";
|
|
7
|
-
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScopedBezierPointFromDucPoint } from "../../technical/scopes";
|
|
8
8
|
export const getRadianFromDegrees = (degrees) => {
|
|
9
9
|
return degrees * (Math.PI / 180);
|
|
10
10
|
};
|
package/dist/utils/shape.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BEZIER_MIRRORING } from "../
|
|
1
|
+
import { BEZIER_MIRRORING } from "../enums";
|
|
2
|
+
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped } from "../technical/scopes";
|
|
2
3
|
import { isArrowElement, isEllipseElement, isFreeDrawElement, isLinearElement, isPolygonElement } from "../types/elements/typeChecks";
|
|
3
4
|
import { calculateShapeBounds } from "./bounds";
|
|
4
5
|
import { getBaseElementProps } from "./elements";
|
|
5
6
|
import { getNormalizedPoints, mergeOverlappingPoints } from "./elements/linearElement";
|
|
6
7
|
import { newLinearElement } from "./elements/newElement";
|
|
7
8
|
import { rotatePoint } from "./math";
|
|
8
|
-
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped } from "../technical/scopes";
|
|
9
9
|
/**
|
|
10
10
|
* Converts a shape (rectangle, polygon, ellipse) to a linear element
|
|
11
11
|
*/
|
|
@@ -1,63 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { PRUNING_LEVEL, TEXT_ALIGN } from "../../
|
|
3
|
-
import {
|
|
1
|
+
import { isFiniteNumber } from "..";
|
|
2
|
+
import { PRUNING_LEVEL, TEXT_ALIGN } from "../../enums";
|
|
3
|
+
import { isValidPrecisionScopeValue } from "../../restore/restoreDataState";
|
|
4
4
|
import { getPrecisionValueFromRaw, getScaledZoomValueForScope, getScopedZoomValue, NEUTRAL_SCOPE, } from "../../technical/scopes";
|
|
5
5
|
import { COLOR_PALETTE, DEFAULT_ELEMENT_PROPS, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, } from "../constants";
|
|
6
6
|
import { getNormalizedZoom } from "../normalize";
|
|
7
|
-
import { isFiniteNumber } from "..";
|
|
8
|
-
import { isValidPrecisionScopeValue } from "../../restore/restoreDataState";
|
|
9
|
-
// appState
|
|
10
|
-
// export const updateActiveTool = (
|
|
11
|
-
// appState: Pick<DucLocalState, "activeTool">,
|
|
12
|
-
// data: ((
|
|
13
|
-
// | {
|
|
14
|
-
// type: ToolType;
|
|
15
|
-
// }
|
|
16
|
-
// | { type: "custom"; customType: string }
|
|
17
|
-
// ) & { locked?: boolean; fromSelection?: boolean }) & {
|
|
18
|
-
// lastActiveToolBeforeEraser?: ActiveTool | null;
|
|
19
|
-
// },
|
|
20
|
-
// ): DucLocalState["activeTool"] => {
|
|
21
|
-
// if (data.type === "custom") {
|
|
22
|
-
// return {
|
|
23
|
-
// ...appState.activeTool,
|
|
24
|
-
// type: "custom",
|
|
25
|
-
// customType: data.customType,
|
|
26
|
-
// locked: data.locked ?? appState.activeTool.locked,
|
|
27
|
-
// };
|
|
28
|
-
// }
|
|
29
|
-
// return {
|
|
30
|
-
// ...appState.activeTool,
|
|
31
|
-
// lastActiveTool:
|
|
32
|
-
// data.lastActiveToolBeforeEraser === undefined
|
|
33
|
-
// ? appState.activeTool.lastActiveTool
|
|
34
|
-
// : data.lastActiveToolBeforeEraser,
|
|
35
|
-
// type: data.type,
|
|
36
|
-
// customType: null,
|
|
37
|
-
// locked: data.locked ?? appState.activeTool.locked,
|
|
38
|
-
// fromSelection: data.fromSelection ?? false,
|
|
39
|
-
// };
|
|
40
|
-
// };
|
|
41
|
-
// activeTool: {
|
|
42
|
-
// type: "selection",
|
|
43
|
-
// customType: null,
|
|
44
|
-
// locked: DEFAULT_ELEMENT_PROPS.locked,
|
|
45
|
-
// fromSelection: false,
|
|
46
|
-
// lastActiveTool: null,
|
|
47
|
-
// },
|
|
48
|
-
// duconfig
|
|
49
|
-
// displayAllPointDistances: false,
|
|
50
|
-
// displayDistanceOnDrawing: true,
|
|
51
|
-
// displayAllPointInfoSelected: false,
|
|
52
|
-
// displayAllPointCoordinates: false,
|
|
53
|
-
// displayRootAxis: false,
|
|
54
|
-
// showHyperlinkPopup: false,
|
|
55
|
-
// antiAliasing: ANTI_ALIASING.ANALYTIC,
|
|
56
|
-
// vSync: true,
|
|
57
|
-
// zoomStep: 0,
|
|
58
|
-
// scaleRatioLocked: false,
|
|
59
|
-
// theme: THEME.LIGHT,
|
|
60
|
-
// debugRendering: false,
|
|
61
7
|
/**
|
|
62
8
|
* Returns the zoom object with value, scoped, and scaled properties,
|
|
63
9
|
* using importedState, restoredGlobalState, and defaults.
|
|
@@ -78,16 +24,8 @@ export const getDefaultGlobalState = () => {
|
|
|
78
24
|
return {
|
|
79
25
|
name: null,
|
|
80
26
|
viewBackgroundColor: typeof window !== "undefined" ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? COLOR_PALETTE.night : COLOR_PALETTE.white) : COLOR_PALETTE.white,
|
|
81
|
-
scopeExponentThreshold:
|
|
27
|
+
scopeExponentThreshold: 3,
|
|
82
28
|
mainScope: NEUTRAL_SCOPE,
|
|
83
|
-
dashSpacingScale: 1,
|
|
84
|
-
isDashSpacingAffectedByViewportScale: false,
|
|
85
|
-
dimensionsAssociativeByDefault: false,
|
|
86
|
-
useAnnotativeScaling: false,
|
|
87
|
-
displayPrecision: {
|
|
88
|
-
linear: 2,
|
|
89
|
-
angular: 1,
|
|
90
|
-
},
|
|
91
29
|
pruningLevel: PRUNING_LEVEL.BALANCED,
|
|
92
30
|
};
|
|
93
31
|
};
|
|
@@ -99,7 +37,6 @@ export const getDefaultLocalState = () => {
|
|
|
99
37
|
const scopedZoom = getScopedZoomValue(zoom, scope);
|
|
100
38
|
return {
|
|
101
39
|
scope,
|
|
102
|
-
activeStandardId: PREDEFINED_STANDARDS.DUC,
|
|
103
40
|
isBindingEnabled: true,
|
|
104
41
|
scrollX: getPrecisionValueFromRaw(scrollX, NEUTRAL_SCOPE, scope),
|
|
105
42
|
scrollY: getPrecisionValueFromRaw(scrollY, NEUTRAL_SCOPE, scope),
|
|
@@ -117,15 +54,12 @@ export const getDefaultLocalState = () => {
|
|
|
117
54
|
currentItemFontSize: getPrecisionValueFromRaw(DEFAULT_FONT_SIZE, scope, scope),
|
|
118
55
|
currentItemOpacity: DEFAULT_ELEMENT_PROPS.opacity,
|
|
119
56
|
currentItemRoundness: getPrecisionValueFromRaw(0, scope, scope),
|
|
120
|
-
activeGridSettings: [],
|
|
121
|
-
activeSnapSettings: "",
|
|
122
57
|
penMode: false,
|
|
123
58
|
viewModeEnabled: false,
|
|
124
59
|
objectsSnapModeEnabled: true,
|
|
125
60
|
gridModeEnabled: false,
|
|
126
61
|
outlineModeEnabled: false,
|
|
127
62
|
manualSaveMode: false,
|
|
128
|
-
|
|
129
|
-
gridStep: 10,
|
|
63
|
+
decimalPlaces: 2,
|
|
130
64
|
};
|
|
131
65
|
};
|
package/dist/utils/traverse.d.ts
CHANGED
|
@@ -20,3 +20,11 @@ import { Scope } from "../types";
|
|
|
20
20
|
* @param detectedScope - Internally tracked scope for the current level
|
|
21
21
|
*/
|
|
22
22
|
export declare const traverseAndUpdatePrecisionValues: (obj: any, targetScope: Scope, providedScope?: Scope, visited?: WeakSet<WeakKey>, detectedScope?: Scope) => any;
|
|
23
|
+
/**
|
|
24
|
+
* Traverses an object and normalizes it for serialization in `targetScope`.
|
|
25
|
+
*
|
|
26
|
+
* - Converts all PrecisionValue fields so `scoped` is in `targetScope`
|
|
27
|
+
* - Rewrites PrecisionValue `value` from the computed `scoped` value
|
|
28
|
+
* - Rewrites `scope` / `mainScope` string fields to `targetScope`
|
|
29
|
+
*/
|
|
30
|
+
export declare const normalizeForSerializationScope: <T>(obj: T, targetScope: Scope, providedScope?: Scope) => T;
|
package/dist/utils/traverse.js
CHANGED
|
@@ -85,3 +85,40 @@ export const traverseAndUpdatePrecisionValues = (obj, targetScope, providedScope
|
|
|
85
85
|
}
|
|
86
86
|
return result;
|
|
87
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Traverses an object and normalizes it for serialization in `targetScope`.
|
|
90
|
+
*
|
|
91
|
+
* - Converts all PrecisionValue fields so `scoped` is in `targetScope`
|
|
92
|
+
* - Rewrites PrecisionValue `value` from the computed `scoped` value
|
|
93
|
+
* - Rewrites `scope` / `mainScope` string fields to `targetScope`
|
|
94
|
+
*/
|
|
95
|
+
export const normalizeForSerializationScope = (obj, targetScope, providedScope) => {
|
|
96
|
+
const converted = traverseAndUpdatePrecisionValues(obj, targetScope, providedScope);
|
|
97
|
+
return rewriteScopeAndPrecisionValues(converted, targetScope);
|
|
98
|
+
};
|
|
99
|
+
const rewriteScopeAndPrecisionValues = (obj, targetScope, visited = new WeakSet()) => {
|
|
100
|
+
if (obj == null || typeof obj !== "object")
|
|
101
|
+
return obj;
|
|
102
|
+
if (isPrecisionValue(obj)) {
|
|
103
|
+
return Object.assign(Object.assign({}, obj), { value: obj.scoped });
|
|
104
|
+
}
|
|
105
|
+
if (Array.isArray(obj)) {
|
|
106
|
+
return obj.map((item) => rewriteScopeAndPrecisionValues(item, targetScope, visited));
|
|
107
|
+
}
|
|
108
|
+
if (visited.has(obj))
|
|
109
|
+
return obj;
|
|
110
|
+
visited.add(obj);
|
|
111
|
+
if (obj.constructor !== Object) {
|
|
112
|
+
return obj;
|
|
113
|
+
}
|
|
114
|
+
const result = {};
|
|
115
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
116
|
+
if ((key === "scope" || key === "mainScope") &&
|
|
117
|
+
typeof value === "string") {
|
|
118
|
+
result[key] = targetScope;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
result[key] = rewriteScopeAndPrecisionValues(value, targetScope, visited);
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { VersionGraph } from "./types";
|
|
2
|
+
export interface RestoredVersion {
|
|
3
|
+
versionNumber: number;
|
|
4
|
+
schemaVersion: number;
|
|
5
|
+
data: Uint8Array;
|
|
6
|
+
fromCheckpoint: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface VersionEntry {
|
|
9
|
+
id: string;
|
|
10
|
+
versionNumber: number;
|
|
11
|
+
schemaVersion: number;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
description?: string;
|
|
14
|
+
isManualSave: boolean;
|
|
15
|
+
userId?: string;
|
|
16
|
+
versionType: "checkpoint" | "delta";
|
|
17
|
+
sizeBytes: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Restore the full document state at a specific version number.
|
|
21
|
+
*
|
|
22
|
+
* If the version corresponds to a checkpoint, the raw data is returned directly.
|
|
23
|
+
* Otherwise, the nearest preceding checkpoint is loaded and deltas are replayed
|
|
24
|
+
* on top of it to reconstruct the state.
|
|
25
|
+
*
|
|
26
|
+
* All heavy lifting (SQLite access, decompression, delta replay) happens in
|
|
27
|
+
* Rust/WASM.
|
|
28
|
+
*/
|
|
29
|
+
export declare const restoreVersion: (ducBuffer: Uint8Array, versionNumber: number) => Promise<RestoredVersion>;
|
|
30
|
+
/**
|
|
31
|
+
* Restore a specific checkpoint by its ID.
|
|
32
|
+
*/
|
|
33
|
+
export declare const restoreCheckpoint: (ducBuffer: Uint8Array, checkpointId: string) => Promise<RestoredVersion>;
|
|
34
|
+
/**
|
|
35
|
+
* List all versions (checkpoints and deltas) in the .duc file,
|
|
36
|
+
* ordered by version number descending. Does not load data blobs.
|
|
37
|
+
*/
|
|
38
|
+
export declare const listVersions: (ducBuffer: Uint8Array) => Promise<VersionEntry[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Read the full version graph from the .duc file, including all
|
|
41
|
+
* checkpoints, deltas, chains, and metadata.
|
|
42
|
+
*/
|
|
43
|
+
export declare const readVersionGraph: (ducBuffer: Uint8Array) => Promise<VersionGraph | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Revert the document to a specific version, deleting all versions
|
|
46
|
+
* newer than the target. Returns the restored state at that version.
|
|
47
|
+
*
|
|
48
|
+
* **Warning**: This mutates the .duc buffer in-place (via the WASM
|
|
49
|
+
* SQLite connection). The returned `RestoredVersion.data` contains the
|
|
50
|
+
* full document state at the target version.
|
|
51
|
+
*/
|
|
52
|
+
export declare const revertToVersion: (ducBuffer: Uint8Array, targetVersion: number) => Promise<RestoredVersion>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the current version-control schema version from Rust.
|
|
55
|
+
*
|
|
56
|
+
* This is the single source of truth for the schema version number,
|
|
57
|
+
* generated from `schema/duc.sql` (`PRAGMA user_version`) at build time.
|
|
58
|
+
* The version control system handles migration bookkeeping automatically
|
|
59
|
+
* on the next checkpoint or delta creation.
|
|
60
|
+
*/
|
|
61
|
+
export declare const getCurrentSchemaVersion: () => Promise<number>;
|