@fulate/tools 1.0.9 → 1.0.11

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Element, ElementProperties, ElementTransform, Layer, isFormControlTarget, projectConnectionPortPoint, resolveOrigin, resolveReferenceTransform } from "@fulate/core";
2
2
  import { BaseLine, ContentEditingCapabilityToken, DEFAULT_LINE_TREE_BRANCH_STYLE, Group, Line, LineTree, PointEditingCapabilityToken, SelectionBehaviorCapabilityToken, SelectionBehaviorMode, SelectionDiveMode, SelectionSnapMode, SnapSourceCapabilityToken, TransformInteractionCapabilityToken, addLineTreeBranchAtTail, applyLineTreeTopologyDelta, connectionPortAccepts, createLineTreeTopology, createLineTreeTopologyDelta, getEditorCapability, getEditorFrameFlush, getEndpointRelationIndex, hasConnectionPortCapacity, isEndpointRelationSource, moveLineTreePoint, remapLineTreeRelations, resolveConnectEndpointChange, resolveConnectionPortChanges, resolveDisconnectEndpointChanges, resolveSelectionFrameBounds, workspaceFocusInsetsKey } from "@fulate/ui";
3
3
  import { Bound, Intersection, isIdentityMatrix, qrDecompose, transformPoint } from "@fulate/share";
4
+ import { cloneDeep, has, isNull, isString, isUndefined, last } from "lodash-es";
4
5
  import { deserializeElement } from "@fulate/import";
5
- import { isNull, isString, isUndefined } from "lodash-es";
6
6
  import RBush from "rbush";
7
7
  //#region packages/tools/src/select/checkElement.ts
8
8
  function isSelectable(element, excludes) {
@@ -2404,7 +2404,7 @@ var EditorInteractionController = class {
2404
2404
  kind: "endpoint-binding",
2405
2405
  target: session.tailTarget
2406
2406
  } : void 0);
2407
- const tailAnchorId = added.topology.branches.find(({ subpathId }) => subpathId === added.subpathId).vertices.at(-1).anchorId;
2407
+ const tailAnchorId = last(added.topology.branches.find(({ subpathId }) => subpathId === added.subpathId).vertices).anchorId;
2408
2408
  const scope = this.history.openScope(this.selection);
2409
2409
  this.applyAuthoredBatch([{
2410
2410
  owner: session.owner,
@@ -2533,7 +2533,7 @@ var EditorInteractionController = class {
2533
2533
  }) });
2534
2534
  const bindable = line.getBindableEndpoints();
2535
2535
  const headSource = bindable[0]?.ref;
2536
- const tailSource = bindable.at(-1)?.ref;
2536
+ const tailSource = last(bindable)?.ref;
2537
2537
  const structure = [{
2538
2538
  owner: parent,
2539
2539
  children: [...parent.children, line]
@@ -2621,7 +2621,7 @@ function getEditorInteractionController(root) {
2621
2621
  //#endregion
2622
2622
  //#region packages/tools/src/history/index.ts
2623
2623
  function cloneHistoryValue(value) {
2624
- return value !== null && typeof value === "object" ? structuredClone(value) : value;
2624
+ return value !== null && typeof value === "object" ? cloneDeep(value) : value;
2625
2625
  }
2626
2626
  function selectionKeys(elements) {
2627
2627
  return elements.map((element) => element.key);
@@ -2864,7 +2864,7 @@ var HistoryManager = class {
2864
2864
  */
2865
2865
  undo() {
2866
2866
  this.selectionAdapter?.finishInteraction();
2867
- const entry = this.undoStack.at(-1);
2867
+ const entry = last(this.undoStack);
2868
2868
  if (!entry) return;
2869
2869
  const result = this.replay(entry, "before", entry.selectionBefore);
2870
2870
  this.undoStack.pop();
@@ -2877,7 +2877,7 @@ var HistoryManager = class {
2877
2877
  */
2878
2878
  redo() {
2879
2879
  this.selectionAdapter?.finishInteraction();
2880
- const entry = this.redoStack.at(-1);
2880
+ const entry = last(this.redoStack);
2881
2881
  if (!entry) return;
2882
2882
  const result = this.replay(entry, "after", entry.selectionAfter);
2883
2883
  this.redoStack.pop();
@@ -2912,7 +2912,7 @@ function resolveOffsets(rects, type) {
2912
2912
  if (type === "justify-between") {
2913
2913
  rects.sort((left, right) => left.left - right.left);
2914
2914
  const start = rects[0].left;
2915
- const end = rects.at(-1);
2915
+ const end = last(rects);
2916
2916
  const total = rects.reduce((sum, rect) => sum + rect.width, 0);
2917
2917
  const gap = (end.left + end.width - start - total) / (rects.length - 1);
2918
2918
  let x = start;
@@ -2945,7 +2945,7 @@ function resolveOffsets(rects, type) {
2945
2945
  }
2946
2946
  rects.sort((left, right) => left.top - right.top);
2947
2947
  const start = rects[0].top;
2948
- const end = rects.at(-1);
2948
+ const end = last(rects);
2949
2949
  const total = rects.reduce((sum, rect) => sum + rect.height, 0);
2950
2950
  const gap = (end.top + end.height - start - total) / (rects.length - 1);
2951
2951
  let y = start;
@@ -3284,7 +3284,7 @@ function referenceChanges(elements, keyMap) {
3284
3284
  function deserializeClones(entries, deserializers) {
3285
3285
  const keyMap = /* @__PURE__ */ new Map();
3286
3286
  const elements = entries.map((entry) => {
3287
- const json = structuredClone(entry);
3287
+ const json = cloneDeep(entry);
3288
3288
  removeKeys(json);
3289
3289
  offsetTopLevel(json);
3290
3290
  const element = deserializeElement(json, deserializers);
@@ -4853,14 +4853,14 @@ var Rule = class extends Element {
4853
4853
  if (!options) return this;
4854
4854
  const { rulerSize, backgroundColor, cornerBackgroundColor, majorTickColor, minorTickColor, borderColor, textColor, selectionColor, ...baseOptions } = options;
4855
4855
  let changed = false;
4856
- if (Object.hasOwn(options, "rulerSize")) changed = this.setAppearance("rulerSize", rulerSize ?? DEFAULT_RULER_SIZE) || changed;
4857
- if (Object.hasOwn(options, "backgroundColor")) changed = this.setAppearance("backgroundColor", backgroundColor ?? DEFAULT_BACKGROUND_COLOR) || changed;
4858
- if (Object.hasOwn(options, "cornerBackgroundColor")) changed = this.setAppearance("cornerBackgroundColor", cornerBackgroundColor ?? DEFAULT_CORNER_BACKGROUND_COLOR) || changed;
4859
- if (Object.hasOwn(options, "majorTickColor")) changed = this.setAppearance("majorTickColor", majorTickColor ?? DEFAULT_MAJOR_TICK_COLOR) || changed;
4860
- if (Object.hasOwn(options, "minorTickColor")) changed = this.setAppearance("minorTickColor", minorTickColor ?? DEFAULT_MINOR_TICK_COLOR) || changed;
4861
- if (Object.hasOwn(options, "borderColor")) changed = this.setAppearance("borderColor", borderColor ?? DEFAULT_BORDER_COLOR) || changed;
4862
- if (Object.hasOwn(options, "textColor")) changed = this.setAppearance("textColor", textColor ?? DEFAULT_TEXT_COLOR) || changed;
4863
- if (Object.hasOwn(options, "selectionColor")) changed = this.setAppearance("selectionColor", selectionColor) || changed;
4856
+ if (has(options, "rulerSize")) changed = this.setAppearance("rulerSize", rulerSize ?? DEFAULT_RULER_SIZE) || changed;
4857
+ if (has(options, "backgroundColor")) changed = this.setAppearance("backgroundColor", backgroundColor ?? DEFAULT_BACKGROUND_COLOR) || changed;
4858
+ if (has(options, "cornerBackgroundColor")) changed = this.setAppearance("cornerBackgroundColor", cornerBackgroundColor ?? DEFAULT_CORNER_BACKGROUND_COLOR) || changed;
4859
+ if (has(options, "majorTickColor")) changed = this.setAppearance("majorTickColor", majorTickColor ?? DEFAULT_MAJOR_TICK_COLOR) || changed;
4860
+ if (has(options, "minorTickColor")) changed = this.setAppearance("minorTickColor", minorTickColor ?? DEFAULT_MINOR_TICK_COLOR) || changed;
4861
+ if (has(options, "borderColor")) changed = this.setAppearance("borderColor", borderColor ?? DEFAULT_BORDER_COLOR) || changed;
4862
+ if (has(options, "textColor")) changed = this.setAppearance("textColor", textColor ?? DEFAULT_TEXT_COLOR) || changed;
4863
+ if (has(options, "selectionColor")) changed = this.setAppearance("selectionColor", selectionColor) || changed;
4864
4864
  super.setOptions(baseOptions);
4865
4865
  if (changed) this.transform.markPaintDirty();
4866
4866
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fulate/tools",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",