@fulate/ui 1.0.10 → 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 +20 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { clearCache, layoutNextLineRange, layoutWithLines, materializeLineRange, measureLineStats, measureNaturalWidth, prepareWithSegments } from "@chenglou/pretext";
2
2
  import { ChangeImpact, CustomEvent, Element, ElementProperties, ElementTransform, SKIN_DEFAULTS, Shape, ShapeProperties, ShapeTransform, createAuthoredLineSubpath, createGeometrySnapshot, createLineSubpath, createPathLocalId, evaluatePathSegmentPoint, getElementConnectionPort, getElementConnectionPortPoint, isReparentTransformIntent, resolveAuthoredGeometryFramePatch, resolveAuthoredSubpath, resolveReferenceTransform, resolveReferenceTransformTarget, splitPathSegment } from "@fulate/core";
3
- import { clamp, isFunction, isNil, isNull, isString, isUndefined } from "lodash-es";
3
+ import { clamp, has, isFunction, isNil, isNull, isString, isUndefined, last } from "lodash-es";
4
4
  import { Bound, Intersection, createCanvasGradient, createPointView, isGradient, isIdentityMatrix, isPointWithinDistance, rectEdgePosition, transformPoint } from "@fulate/share";
5
5
  import { computePosition as computePosition$1, flip, offset, shift } from "@floating-ui/core";
6
6
  import { Easing, Tween } from "@tweenjs/tween.js";
@@ -1589,7 +1589,7 @@ function resolveConnectionPortChanges(root, changes) {
1589
1589
  let sources;
1590
1590
  let index;
1591
1591
  for (const { owner, patch } of changes) {
1592
- if (owner.activeRoot !== root || !Object.hasOwn(patch, "ports")) continue;
1592
+ if (owner.activeRoot !== root || !has(patch, "ports")) continue;
1593
1593
  const next = resolveConfiguredPorts(patch.ports);
1594
1594
  if (Object.is(owner.ports, next)) continue;
1595
1595
  const nextIds = new Set(next === false ? [] : next === true ? owner.resolveConnectionPorts(true).map(({ ref }) => ref.portId) : next.map(({ id }) => id));
@@ -1612,7 +1612,7 @@ function resolveConnectionPortChanges(root, changes) {
1612
1612
  */
1613
1613
  function commitConnectionPortPatch(owner, patch) {
1614
1614
  const root = owner.activeRoot;
1615
- if (!root || !Object.hasOwn(patch, "ports")) return false;
1615
+ if (!root || !has(patch, "ports")) return false;
1616
1616
  if (Object.is(owner.ports, resolveConfiguredPorts(patch.ports))) return false;
1617
1617
  root.applyChangeBatch(resolveConnectionPortChanges(root, [{
1618
1618
  owner,
@@ -2487,7 +2487,7 @@ var Polygon = class extends EditorShape {
2487
2487
  super(prepared, new PolygonProperties(prepared), PolygonTransform);
2488
2488
  }
2489
2489
  resolveOptions(options) {
2490
- if (!Object.hasOwn(options, "contour") || options.contour === void 0 || options.contour === this.contour) return options;
2490
+ if (!has(options, "contour") || options.contour === void 0 || options.contour === this.contour) return options;
2491
2491
  return {
2492
2492
  ...options,
2493
2493
  contour: resolveContour(options.contour)
@@ -2796,7 +2796,7 @@ var VectorPath = class extends EditorShape {
2796
2796
  super(prepared, new VectorPathProperties(prepared), VectorPathTransform);
2797
2797
  }
2798
2798
  resolveOptions(options) {
2799
- if (!Object.hasOwn(options, "path") || options.path === void 0 || options.path === this.path) return options;
2799
+ if (!has(options, "path") || options.path === void 0 || options.path === this.path) return options;
2800
2800
  return {
2801
2801
  ...options,
2802
2802
  path: resolveVectorPath(options.path)
@@ -4578,7 +4578,7 @@ function getTransformRelationPatch(line) {
4578
4578
  };
4579
4579
  }
4580
4580
  function applyRelationPatch(options) {
4581
- if (!Object.hasOwn(options, "relations")) return options;
4581
+ if (!has(options, "relations")) return options;
4582
4582
  const relations = options.relations;
4583
4583
  const resolved = { ...options };
4584
4584
  delete resolved.relations;
@@ -4587,13 +4587,13 @@ function applyRelationPatch(options) {
4587
4587
  resolved.tailRelation = void 0;
4588
4588
  return resolved;
4589
4589
  }
4590
- if (Object.hasOwn(relations, "head")) resolved.headRelation = relations.head;
4591
- if (Object.hasOwn(relations, "tail")) resolved.tailRelation = relations.tail;
4590
+ if (has(relations, "head")) resolved.headRelation = relations.head;
4591
+ if (has(relations, "tail")) resolved.tailRelation = relations.tail;
4592
4592
  return resolved;
4593
4593
  }
4594
4594
  function resolveLinePatch(options) {
4595
4595
  let resolved = options;
4596
- if (Object.hasOwn(options, "path") && options.path !== void 0) {
4596
+ if (has(options, "path") && options.path !== void 0) {
4597
4597
  const path = options.path;
4598
4598
  if (Array.isArray(path)) resolved = {
4599
4599
  ...options,
@@ -4638,7 +4638,7 @@ var LineProperties = class extends ElementProperties {
4638
4638
  this.headRelation = void 0;
4639
4639
  this.tailRelation = void 0;
4640
4640
  } else if (this.path.anchors.length === 1) {
4641
- this.headRelation = Object.hasOwn(options, "headRelation") ? options.headRelation : options.tailRelation;
4641
+ this.headRelation = has(options, "headRelation") ? options.headRelation : options.tailRelation;
4642
4642
  this.tailRelation = void 0;
4643
4643
  } else {
4644
4644
  this.headRelation = options.headRelation;
@@ -4937,7 +4937,7 @@ var BaseLine = class extends Element {
4937
4937
  }
4938
4938
  resolveOptions(options) {
4939
4939
  const resolved = resolveLinePatch(options);
4940
- if (!Object.hasOwn(options, "path") && !Object.hasOwn(options, "relations")) return resolved;
4940
+ if (!has(options, "path") && !has(options, "relations")) return resolved;
4941
4941
  const path = resolved.path ?? this.path;
4942
4942
  if (path.anchors.length > 1) return resolved;
4943
4943
  if (path.anchors.length === 0) return {
@@ -4945,8 +4945,8 @@ var BaseLine = class extends Element {
4945
4945
  headRelation: void 0,
4946
4946
  tailRelation: void 0
4947
4947
  };
4948
- const hasHead = Object.hasOwn(resolved, "headRelation");
4949
- const hasTail = Object.hasOwn(resolved, "tailRelation");
4948
+ const hasHead = has(resolved, "headRelation");
4949
+ const hasTail = has(resolved, "tailRelation");
4950
4950
  const head = hasHead ? resolved.headRelation : this.headRelation;
4951
4951
  const tail = hasTail ? resolved.tailRelation : this.tailRelation;
4952
4952
  const anchorId = path.anchors[0].anchorId;
@@ -5006,7 +5006,7 @@ var BaseLine = class extends Element {
5006
5006
  const vertices = this.getEffectiveLineVerticesView();
5007
5007
  let path = this.path;
5008
5008
  if (detachHead) path = replaceAuthoredAnchorPoint(path, head.anchorId, localPositions?.get(head.anchorId) ?? vertices[0].point);
5009
- if (detachTail && tail.anchorId !== head?.anchorId) path = replaceAuthoredAnchorPoint(path, tail.anchorId, localPositions?.get(tail.anchorId) ?? vertices.at(-1).point);
5009
+ if (detachTail && tail.anchorId !== head?.anchorId) path = replaceAuthoredAnchorPoint(path, tail.anchorId, localPositions?.get(tail.anchorId) ?? last(vertices).point);
5010
5010
  return {
5011
5011
  owner: this,
5012
5012
  patch: {
@@ -5086,7 +5086,7 @@ var BaseLine = class extends Element {
5086
5086
  }
5087
5087
  setLocalPoint(anchorId, point, endpointUpdate) {
5088
5088
  const patch = { path: replaceAuthoredAnchorPoint(this.path, anchorId, point) };
5089
- if (endpointUpdate && Object.hasOwn(endpointUpdate, "target")) {
5089
+ if (endpointUpdate && has(endpointUpdate, "target")) {
5090
5090
  const head = this.headAnchor?.anchorId === anchorId;
5091
5091
  const tail = this.tailAnchor?.anchorId === anchorId;
5092
5092
  const relation = endpointUpdate.target && {
@@ -5133,8 +5133,8 @@ var BaseLine = class extends Element {
5133
5133
  const root = this.activeRoot;
5134
5134
  const previousPath = changes.get("path");
5135
5135
  const currentHeadId = current.path.anchors[0]?.anchorId;
5136
- const currentTailId = current.path.anchors.at(-1)?.anchorId;
5137
- const endpointIdsChanged = previousPath !== void 0 && (previousPath.anchors[0]?.anchorId !== currentHeadId || previousPath.anchors.at(-1)?.anchorId !== currentTailId);
5136
+ const currentTailId = last(current.path.anchors)?.anchorId;
5137
+ const endpointIdsChanged = previousPath !== void 0 && (previousPath.anchors[0]?.anchorId !== currentHeadId || last(previousPath.anchors)?.anchorId !== currentTailId);
5138
5138
  if (!root || !endpointIdsChanged && !changes.has("headRelation") && !changes.has("tailRelation")) return;
5139
5139
  this.syncEndpointRelations(root);
5140
5140
  }
@@ -5449,7 +5449,7 @@ function createChildBranchRecords(parentSubpathId, sourceAnchorId, points, style
5449
5449
  };
5450
5450
  }
5451
5451
  function addLineTreeBranchAtTail(topology, parentSubpathId, points, style = DEFAULT_LINE_TREE_BRANCH_STYLE, tailRelation) {
5452
- const sourceAnchorId = getLineTreeBranch(topology, parentSubpathId).vertices.at(-1).anchorId;
5452
+ const sourceAnchorId = last(getLineTreeBranch(topology, parentSubpathId).vertices).anchorId;
5453
5453
  const created = createChildBranchRecords(parentSubpathId, sourceAnchorId, points, style, tailRelation);
5454
5454
  return {
5455
5455
  topology: {
@@ -5735,7 +5735,7 @@ var LineTreeTransform = class extends ElementTransform {
5735
5735
  return this.worldSnapPoints;
5736
5736
  }
5737
5737
  getBranchTailSource(subpathId) {
5738
- const anchorId = this.getBranch(subpathId).vertices.at(-1).anchorId;
5738
+ const anchorId = last(this.getBranch(subpathId).vertices).anchorId;
5739
5739
  return {
5740
5740
  subpathId,
5741
5741
  anchorId,
@@ -5778,7 +5778,7 @@ var LineTreeTransform = class extends ElementTransform {
5778
5778
  //#endregion
5779
5779
  //#region packages/ui/src/line-tree/index.ts
5780
5780
  function prepareTopologyOption(options) {
5781
- return Object.hasOwn(options, "topology") && options.topology === void 0 ? {
5781
+ return has(options, "topology") && options.topology === void 0 ? {
5782
5782
  ...options,
5783
5783
  topology: EMPTY_LINE_TREE_TOPOLOGY
5784
5784
  } : options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fulate/ui",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",