New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@idraw/core

Package Overview
Dependencies
Maintainers
0
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idraw/core - npm Package Compare versions

Comparing version 0.4.0-beta.32 to 0.4.0-beta.33

6

dist/esm/middleware/info/index.js
import { formatNumber, getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot, createUUID, limitAngle, rotatePoint, parseAngleToRadian } from '@idraw/util';
import { keySelectedElementList, keyActionType, keyGroupQueue } from '../selector';
import { keySelectedElementList, keyHoverElement, keyActionType, keyGroupQueue } from '../selector';
import { drawSizeInfoText, drawPositionInfoText, drawAngleInfoText } from './draw-info';

@@ -19,7 +19,9 @@ import { defaltStyle } from './config';

beforeDrawFrame({ snapshot }) {
var _a;
const { sharedStore } = snapshot;
const selectedElementList = sharedStore[keySelectedElementList];
const hoverElement = sharedStore[keyHoverElement];
const actionType = sharedStore[keyActionType];
const groupQueue = sharedStore[keyGroupQueue] || [];
if (selectedElementList.length === 1) {
if (selectedElementList.length === 1 && !((_a = hoverElement === null || hoverElement === void 0 ? void 0 : hoverElement.operations) === null || _a === void 0 ? void 0 : _a.locked)) {
const elem = selectedElementList[0];

@@ -26,0 +28,0 @@ if (elem && ['select', 'drag', 'resize'].includes(actionType)) {

@@ -1,3 +0,3 @@

import { keySelectedElementList, keyActionType, keyGroupQueue } from '../selector';
import { keySelectedElementList, keyHoverElement, keyActionType, keyGroupQueue } from '../selector';
import type { DeepSelectorSharedStorage } from '../selector';
export type DeepInfoSharedStorage = Pick<DeepSelectorSharedStorage, typeof keySelectedElementList | typeof keyActionType | typeof keyGroupQueue>;
export type DeepInfoSharedStorage = Pick<DeepSelectorSharedStorage, typeof keySelectedElementList | typeof keyHoverElement | typeof keyActionType | typeof keyGroupQueue>;

@@ -1,3 +0,3 @@

import type { Element, ElementType, PointSize, RendererDrawElementOptions, ViewContext2D, ViewRectVertexes, ViewScaleInfo, ViewSizeInfo, ElementSizeController, ViewCalculator } from '@idraw/types';
import type { AreaSize, MiddlewareSelectorStyle } from './types';
import type { Element, ElementType, PointSize, RendererDrawElementOptions, ViewContext2D, ViewRectVertexes, ViewScaleInfo, ViewSizeInfo, ElementSizeController, ViewCalculator, MiddlewareSelectorStyle } from '@idraw/types';
import type { AreaSize } from './types';
export declare function drawHoverVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {

@@ -8,3 +8,3 @@ viewScaleInfo: ViewScaleInfo;

}): void;
export declare function drawLockVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {
export declare function drawLockedVertexesWrapper(ctx: ViewContext2D, vertexes: ViewRectVertexes | null, opts: {
viewScaleInfo: ViewScaleInfo;

@@ -11,0 +11,0 @@ viewSizeInfo: ViewSizeInfo;

@@ -13,3 +13,3 @@ import { rotateElementVertexes, calcViewPointSize, calcViewVertexes, calcViewElementSize } from '@idraw/util';

}
export function drawLockVertexesWrapper(ctx, vertexes, opts) {
export function drawLockedVertexesWrapper(ctx, vertexes, opts) {
if (!vertexes) {

@@ -16,0 +16,0 @@ return;

@@ -1,3 +0,3 @@

import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, deepResizeGroupElement } from '@idraw/util';
import { drawHoverVertexesWrapper, drawLockVertexesWrapper, drawArea, drawListArea, drawGroupQueueVertexesWrappers, drawSelectedElementControllersVertexes } from './draw-wrapper';
import { is, calcElementsViewInfo, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcElementSizeController, calcElementCenterFromVertexes, rotatePointInGroup, getGroupQueueFromList, findElementsFromList, findElementsFromListByPositions, getElementPositionFromList, deepResizeGroupElement, getElementSize } from '@idraw/util';
import { drawHoverVertexesWrapper, drawLockedVertexesWrapper, drawArea, drawListArea, drawGroupQueueVertexesWrappers, drawSelectedElementControllersVertexes } from './draw-wrapper';
import { drawReferenceLines } from './draw-reference';

@@ -19,2 +19,4 @@ import { getPointTarget, resizeElement, rotateElement, getSelectedListArea, calcSelectedElementsArea, isElementInGroup, isPointInViewActiveGroup, calcMoveInGroup } from './util';

let prevPoint = null;
let moveOriginalStartPoint = null;
let moveOriginalStartElementSize = null;
let inBusyMode = null;

@@ -253,4 +255,5 @@ sharer.setSharedStorage(keyActionType, null);

pointStart: (e) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
prevPoint = e.point;
moveOriginalStartPoint = e.point;
const groupQueue = sharer.getSharedStorage(keyGroupQueue);

@@ -265,3 +268,3 @@ if ((groupQueue === null || groupQueue === void 0 ? void 0 : groupQueue.length) > 0) {

const target = getPointTarget(e.point, pointTargetBaseOptions());
if (((_a = target === null || target === void 0 ? void 0 : target.elements) === null || _a === void 0 ? void 0 : _a.length) === 1 && ((_c = (_b = target.elements[0]) === null || _b === void 0 ? void 0 : _b.operations) === null || _c === void 0 ? void 0 : _c.lock) === true) {
if (((_a = target === null || target === void 0 ? void 0 : target.elements) === null || _a === void 0 ? void 0 : _a.length) === 1 && ((_c = (_b = target.elements[0]) === null || _b === void 0 ? void 0 : _b.operations) === null || _c === void 0 ? void 0 : _c.locked) === true) {
return;

@@ -272,7 +275,10 @@ }

}
if (target.type === 'over-element' && ((_d = target === null || target === void 0 ? void 0 : target.elements) === null || _d === void 0 ? void 0 : _d.length) === 1) {
if (((_d = target === null || target === void 0 ? void 0 : target.elements) === null || _d === void 0 ? void 0 : _d.length) === 1) {
moveOriginalStartElementSize = getElementSize(target === null || target === void 0 ? void 0 : target.elements[0]);
}
if (target.type === 'over-element' && ((_e = target === null || target === void 0 ? void 0 : target.elements) === null || _e === void 0 ? void 0 : _e.length) === 1) {
updateSelectedElementList([target.elements[0]], { triggerEvent: true });
sharer.setSharedStorage(keyActionType, 'drag');
}
else if ((_e = target.type) === null || _e === void 0 ? void 0 : _e.startsWith('resize-')) {
else if ((_f = target.type) === null || _f === void 0 ? void 0 : _f.startsWith('resize-')) {
sharer.setSharedStorage(keyResizeType, target.type);

@@ -297,19 +303,28 @@ sharer.setSharedStorage(keyActionType, 'resize');

const target = getPointTarget(e.point, Object.assign(Object.assign({}, pointTargetBaseOptions()), { areaSize: listAreaSize, groupQueue: [] }));
if (((_f = target === null || target === void 0 ? void 0 : target.elements) === null || _f === void 0 ? void 0 : _f.length) === 1 && ((_h = (_g = target.elements[0]) === null || _g === void 0 ? void 0 : _g.operations) === null || _h === void 0 ? void 0 : _h.lock) === true) {
return;
}
else {
const isLockedElement = ((_g = target === null || target === void 0 ? void 0 : target.elements) === null || _g === void 0 ? void 0 : _g.length) === 1 && ((_j = (_h = target.elements[0]) === null || _h === void 0 ? void 0 : _h.operations) === null || _j === void 0 ? void 0 : _j.locked) === true;
if (!isLockedElement) {
updateHoverElement(null);
}
if (target.type === 'list-area') {
sharer.setSharedStorage(keyActionType, 'drag-list');
if (((_k = target === null || target === void 0 ? void 0 : target.elements) === null || _k === void 0 ? void 0 : _k.length) === 1) {
moveOriginalStartElementSize = getElementSize(target === null || target === void 0 ? void 0 : target.elements[0]);
}
else if (target.type === 'over-element' && ((_j = target === null || target === void 0 ? void 0 : target.elements) === null || _j === void 0 ? void 0 : _j.length) === 1) {
updateSelectedElementList([target.elements[0]], { triggerEvent: true });
sharer.setSharedStorage(keyActionType, 'drag');
if (!isLockedElement) {
if (target.type === 'list-area') {
sharer.setSharedStorage(keyActionType, 'drag-list');
}
else if (target.type === 'over-element' && ((_l = target === null || target === void 0 ? void 0 : target.elements) === null || _l === void 0 ? void 0 : _l.length) === 1) {
updateSelectedElementList([target.elements[0]], { triggerEvent: true });
sharer.setSharedStorage(keyActionType, 'drag');
}
else if ((_m = target.type) === null || _m === void 0 ? void 0 : _m.startsWith('resize-')) {
sharer.setSharedStorage(keyResizeType, target.type);
sharer.setSharedStorage(keyActionType, 'resize');
}
else {
clear();
sharer.setSharedStorage(keyActionType, 'area');
sharer.setSharedStorage(keyAreaStart, e.point);
updateSelectedElementList([], { triggerEvent: true });
}
}
else if ((_k = target.type) === null || _k === void 0 ? void 0 : _k.startsWith('resize-')) {
sharer.setSharedStorage(keyResizeType, target.type);
sharer.setSharedStorage(keyActionType, 'resize');
}
else {

@@ -332,2 +347,3 @@ clear();

const start = prevPoint;
const originalStart = moveOriginalStartPoint;
const end = e.point;

@@ -340,4 +356,4 @@ const resizeType = sharer.getSharedStorage(keyResizeType);

inBusyMode = 'drag';
if (data && (elems === null || elems === void 0 ? void 0 : elems.length) === 1 && start && end && ((_b = (_a = elems[0]) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.lock) !== true) {
const { moveX, moveY } = calcMoveInGroup(start, end, groupQueue);
if (data && (elems === null || elems === void 0 ? void 0 : elems.length) === 1 && moveOriginalStartElementSize && originalStart && end && ((_b = (_a = elems[0]) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.locked) !== true) {
const { moveX, moveY } = calcMoveInGroup(originalStart, end, groupQueue);
let totalMoveX = calculator.toGridNum(moveX / scale);

@@ -367,4 +383,4 @@ let totalMoveY = calculator.toGridNum(moveY / scale);

}
elems[0].x = calculator.toGridNum(elems[0].x + totalMoveX);
elems[0].y = calculator.toGridNum(elems[0].y + totalMoveY);
elems[0].x = calculator.toGridNum(moveOriginalStartElementSize.x + totalMoveX);
elems[0].y = calculator.toGridNum(moveOriginalStartElementSize.y + totalMoveY);
updateSelectedElementList([elems[0]]);

@@ -387,3 +403,3 @@ calculator.modifyViewVisibleInfoMap(data, {

inBusyMode = 'drag-list';
if (data && start && end && (elems === null || elems === void 0 ? void 0 : elems.length) > 1) {
if (data && originalStart && start && end && (elems === null || elems === void 0 ? void 0 : elems.length) > 1) {
const moveX = (end.x - start.x) / scale;

@@ -393,3 +409,3 @@ const moveY = (end.y - start.y) / scale;

var _a;
if (elem && ((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.lock) !== true) {
if (elem && ((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.locked) !== true) {
elem.x = calculator.toGridNum(elem.x + moveX);

@@ -415,3 +431,3 @@ elem.y = calculator.toGridNum(elem.y + moveY);

else if (actionType === 'resize') {
if (data && (elems === null || elems === void 0 ? void 0 : elems.length) === 1 && start && (resizeType === null || resizeType === void 0 ? void 0 : resizeType.startsWith('resize-'))) {
if (data && (elems === null || elems === void 0 ? void 0 : elems.length) === 1 && originalStart && moveOriginalStartElementSize && (resizeType === null || resizeType === void 0 ? void 0 : resizeType.startsWith('resize-'))) {
inBusyMode = 'resize';

@@ -429,6 +445,6 @@ const pointGroupQueue = [];

});
let resizeStart = start;
let resizeStart = originalStart;
let resizeEnd = end;
if (groupQueue.length > 0) {
resizeStart = rotatePointInGroup(start, pointGroupQueue);
resizeStart = rotatePointInGroup(originalStart, pointGroupQueue);
resizeEnd = rotatePointInGroup(end, pointGroupQueue);

@@ -445,7 +461,7 @@ }

const viewCenter = calcElementCenterFromVertexes(viewVertexes);
const resizedElemSize = rotateElement(elems[0], {
const resizedElemSize = rotateElement(moveOriginalStartElementSize, {
center: viewCenter,
viewScaleInfo,
viewSizeInfo,
start,
start: originalStart,
end,

@@ -458,4 +474,4 @@ resizeType,

else {
const resizedElemSize = resizeElement(elems[0], { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
const calcOpts = { ignore: !!elems[0].angle };
const resizedElemSize = resizeElement(moveOriginalStartElementSize, { scale, start: resizeStart, end: resizeEnd, resizeType, sharer });
const calcOpts = { ignore: !!moveOriginalStartElementSize.angle };
elems[0].x = calculator.toGridNum(resizedElemSize.x, calcOpts);

@@ -507,2 +523,4 @@ elems[0].y = calculator.toGridNum(resizedElemSize.y, calcOpts);

prevPoint = null;
moveOriginalStartPoint = null;
moveOriginalStartElementSize = null;
if (actionType === 'resize' && resizeType) {

@@ -577,2 +595,4 @@ sharer.setSharedStorage(keyResizeType, null);

prevPoint = null;
moveOriginalStartPoint = null;
moveOriginalStartElementSize = null;
clear();

@@ -589,3 +609,3 @@ viewer.drawFrame();

sharer.setSharedStorage(keySelectedElementList, []);
if (target.elements.length === 1 && ((_b = (_a = target.elements[0]) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.lock) === true) {
if (target.elements.length === 1 && ((_b = (_a = target.elements[0]) === null || _a === void 0 ? void 0 : _a.operations) === null || _b === void 0 ? void 0 : _b.locked) === true) {
return;

@@ -637,8 +657,8 @@ }

: null;
const isLock = !!((_a = hoverElement === null || hoverElement === void 0 ? void 0 : hoverElement.operations) === null || _a === void 0 ? void 0 : _a.lock);
const isLocked = !!((_a = hoverElement === null || hoverElement === void 0 ? void 0 : hoverElement.operations) === null || _a === void 0 ? void 0 : _a.locked);
if ((groupQueue === null || groupQueue === void 0 ? void 0 : groupQueue.length) > 0) {
drawGroupQueueVertexesWrappers(overlayContext, groupQueueVertexesList, drawBaseOpts);
if (hoverElement && actionType !== 'drag') {
if (isLock) {
drawLockVertexesWrapper(overlayContext, hoverElementVertexes, Object.assign(Object.assign({}, drawBaseOpts), { controller: calcElementSizeController(hoverElement, {
if (isLocked) {
drawLockedVertexesWrapper(overlayContext, hoverElementVertexes, Object.assign(Object.assign({}, drawBaseOpts), { controller: calcElementSizeController(hoverElement, {
groupQueue,

@@ -653,3 +673,3 @@ controllerSize: 10,

}
if (!isLock && elem && ['select', 'drag', 'resize'].includes(actionType)) {
if (!isLocked && elem && ['select', 'drag', 'resize'].includes(actionType)) {
drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', style }));

@@ -681,4 +701,4 @@ if (actionType === 'drag') {

if (hoverElement && actionType !== 'drag') {
if (isLock) {
drawLockVertexesWrapper(overlayContext, hoverElementVertexes, Object.assign(Object.assign({}, drawBaseOpts), { controller: calcElementSizeController(hoverElement, {
if (isLocked) {
drawLockedVertexesWrapper(overlayContext, hoverElementVertexes, Object.assign(Object.assign({}, drawBaseOpts), { controller: calcElementSizeController(hoverElement, {
groupQueue,

@@ -693,3 +713,3 @@ controllerSize: 10,

}
if (!isLock && elem && ['select', 'drag', 'resize'].includes(actionType)) {
if (!isLocked && elem && ['select', 'drag', 'resize'].includes(actionType)) {
drawSelectedElementControllersVertexes(overlayContext, selectedElementController, Object.assign(Object.assign({}, drawBaseOpts), { element: elem, calculator, hideControllers: !!isMoving && actionType === 'drag', style }));

@@ -696,0 +716,0 @@ if (actionType === 'drag') {

@@ -26,3 +26,3 @@ import type { ViewRectVertexes, ElementSizeController, StoreSharer, ViewScaleInfo, ViewSizeInfo } from '@idraw/types';

}): PointTarget;
export declare function resizeElement(elem: Element<ElementType>, opts: {
export declare function resizeElement(elem: ElementSize, opts: {
start: PointSize;

@@ -34,3 +34,3 @@ end: PointSize;

}): ElementSize;
export declare function rotateElement(elem: Element<ElementType>, opts: {
export declare function rotateElement(elem: ElementSize, opts: {
center: PointSize;

@@ -37,0 +37,0 @@ start: PointSize;

@@ -706,6 +706,6 @@ import { calcElementCenter, rotateElementVertexes, calcElementVertexesInGroup, calcElementQueueVertexesQueueInGroup, calcViewPointSize, calcViewElementSize, rotatePointInGroup, rotatePoint, parseAngleToRadian, parseRadianToAngle, limitAngle, calcRadian } from '@idraw/util';

const elem = data.elements[idx];
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.lock) === true) {
if (((_a = elem === null || elem === void 0 ? void 0 : elem.operations) === null || _a === void 0 ? void 0 : _a.locked) === true) {
continue;
}
const elemSize = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
const elemSize = calcViewElementSize(elem, { viewScaleInfo });
const center = calcElementCenter(elemSize);

@@ -737,3 +737,3 @@ if (center.x >= startX && center.x <= endX && center.y >= startY && center.y <= endY) {

const area = { x: 0, y: 0, w: 0, h: 0 };
const { viewScaleInfo, viewSizeInfo } = opts;
const { viewScaleInfo } = opts;
let prevElemSize = null;

@@ -745,3 +745,3 @@ for (let i = 0; i < elements.length; i++) {

}
const elemSize = calcViewElementSize(elem, { viewScaleInfo, viewSizeInfo });
const elemSize = calcViewElementSize(elem, { viewScaleInfo });
if (elemSize.angle && (elemSize.angle > 0 || elemSize.angle < 0)) {

@@ -748,0 +748,0 @@ const ves = rotateElementVertexes(elemSize);

{
"name": "@idraw/core",
"version": "0.4.0-beta.32",
"version": "0.4.0-beta.33",
"description": "",

@@ -24,9 +24,9 @@ "main": "dist/esm/index.js",

"devDependencies": {
"@idraw/types": "^0.4.0-beta.32"
"@idraw/types": "^0.4.0-beta.33"
},
"dependencies": {},
"peerDependencies": {
"@idraw/board": "^0.4.0-beta.32",
"@idraw/renderer": "^0.4.0-beta.32",
"@idraw/util": "^0.4.0-beta.32"
"@idraw/board": "^0.4.0-beta.33",
"@idraw/renderer": "^0.4.0-beta.33",
"@idraw/util": "^0.4.0-beta.33"
},

@@ -33,0 +33,0 @@ "publishConfig": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc