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

@tldraw/primitives

Package Overview
Dependencies
Maintainers
4
Versions
461
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tldraw/primitives - npm Package Compare versions

Comparing version

to
2.0.0-canary.83a391b46bff

dist-cjs/lib/BaseSegment2d.js

62

CHANGELOG.md

@@ -0,1 +1,63 @@

# v2.0.0-alpha.13 (Wed Jun 28 2023)
### Release Notes
#### [refactor] snapping ([#1589](https://github.com/tldraw/tldraw/pull/1589))
- [editor] fix bug in snapping
#### Fix arrows with weird bends crashing ([#1540](https://github.com/tldraw/tldraw/pull/1540))
- Fixed a rare crash that could happen when you try to curve an arrow with zero distance.
#### [2/3] renderer changes to support "sandwich mode" highlighting ([#1418](https://github.com/tldraw/tldraw/pull/1418))
[not yet!]
#### Measure individual words instead of just line breaks for text exports ([#1397](https://github.com/tldraw/tldraw/pull/1397))
- Add a brief release note for your PR here.
#### avoid lazy race conditions ([#1364](https://github.com/tldraw/tldraw/pull/1364))
[internal only]
---
#### 🚀 Enhancement
- [2/3] renderer changes to support "sandwich mode" highlighting [#1418](https://github.com/tldraw/tldraw/pull/1418) ([@SomeHats](https://github.com/SomeHats))
#### 🐛 Bug Fix
- [refactor] snapping [#1589](https://github.com/tldraw/tldraw/pull/1589) ([@steveruizok](https://github.com/steveruizok))
- Fix arrows with weird bends crashing [#1540](https://github.com/tldraw/tldraw/pull/1540) ([@TodePond](https://github.com/TodePond))
- ensure that fixed points stay fixed [#1523](https://github.com/tldraw/tldraw/pull/1523) ([@steveruizok](https://github.com/steveruizok))
- Measure individual words instead of just line breaks for text exports [#1397](https://github.com/tldraw/tldraw/pull/1397) ([@SomeHats](https://github.com/SomeHats))
- readmes [#1195](https://github.com/tldraw/tldraw/pull/1195) ([@steveruizok](https://github.com/steveruizok))
- [chore] update lazyrepo [#1211](https://github.com/tldraw/tldraw/pull/1211) ([@ds300](https://github.com/ds300))
- Use `strokePathData` for `<ShapeFill/>` path to avoid bugs in the inner path algo [#1207](https://github.com/tldraw/tldraw/pull/1207) ([@orangemug](https://github.com/orangemug) [@steveruizok](https://github.com/steveruizok))
- [lite] upgrade lazyrepo [#1198](https://github.com/tldraw/tldraw/pull/1198) ([@ds300](https://github.com/ds300))
- transfer-out: transfer out [#1195](https://github.com/tldraw/tldraw/pull/1195) ([@SomeHats](https://github.com/SomeHats))
#### ⚠️ Pushed to `main`
- update lazyrepo ([@ds300](https://github.com/ds300))
#### 🏠 Internal
- replace console.log with nicelog [#1496](https://github.com/tldraw/tldraw/pull/1496) ([@steveruizok](https://github.com/steveruizok))
- [chore] remove benchmark [#1489](https://github.com/tldraw/tldraw/pull/1489) ([@steveruizok](https://github.com/steveruizok))
- avoid lazy race conditions [#1364](https://github.com/tldraw/tldraw/pull/1364) ([@SomeHats](https://github.com/SomeHats))
#### Authors: 5
- alex ([@SomeHats](https://github.com/SomeHats))
- David Sheldrick ([@ds300](https://github.com/ds300))
- Lu Wilson ([@TodePond](https://github.com/TodePond))
- Orange Mug ([@orangemug](https://github.com/orangemug))
- Steve Ruiz ([@steveruizok](https://github.com/steveruizok))
---
# v2.0.0-alpha.12 (Mon Apr 03 2023)

@@ -2,0 +64,0 @@

24

dist-cjs/index.d.ts

@@ -225,2 +225,3 @@ import { Box2dModel } from '@tldraw/tlschema';

resize(handle: SelectionCorner | SelectionEdge | string, dx: number, dy: number): void;
union(box: Box2dModel): this;
static From(box: Box2dModel): Box2d;

@@ -250,3 +251,3 @@ static FromPoints(points: VecLike[]): Box2d;

*/
export declare function canolicalizeRotation(a: number): number;
export declare function canonicalizeRotation(a: number): number;

@@ -385,2 +386,5 @@ /**

/** @public */
export declare function getDrawLinePathData(id: string, outline: VecLike[], strokeWidth: number): string[];
/** @public */
export declare function getHeight(pts: VecLike[]): number;

@@ -420,2 +424,8 @@

/** @public */
export declare function getRoundedInkyPolygonPath(points: VecLike[]): string;
/** @public */
export declare function getRoundedPolygonPoints(id: string, outline: VecLike[], offset: number, roundness: number, passes: number): VecLike[];
/**

@@ -580,2 +590,8 @@ * Gets the width/height of a star given its input bounds.

/**
* Check if a float is safe to use. ie: Not too big or small.
* @public
*/
export declare const isSafeFloat: (n: number) => boolean;
/** @public */

@@ -976,2 +992,7 @@ export declare function isSelectionCorner(selection: string): selection is SelectionCorner;

/**
* @public
*/
export declare function toFixed(v: number): number;
/**
* Get a number to a precision.

@@ -1093,2 +1114,3 @@ *

static ToAngle(A: VecLike): number;
static FromAngle(r: number, length?: number): Vec2d;
static ToArray(A: VecLike): number[];

@@ -1095,0 +1117,0 @@ static ToJson(A: VecLike): {

@@ -6,2 +6,6 @@ "use strict";

var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {

@@ -15,7 +19,102 @@ if (from && typeof from === "object" || typeof from === "function") {

};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export(src_exports, {
Box2d: () => import_Box2d.Box2d,
CubicSegment2d: () => import_CubicSegment2d.CubicSegment2d,
CubicSpline2d: () => import_CubicSpline2d.CubicSpline2d,
EASINGS: () => import_easings.EASINGS,
EPSILON: () => import_utils.EPSILON,
LineSegment2d: () => import_LineSegment2d.LineSegment2d,
Matrix2d: () => import_Matrix2d.Matrix2d,
PI: () => import_utils.PI,
PI2: () => import_utils.PI2,
Polyline2d: () => import_Polyline2d.Polyline2d,
ROTATE_CORNER_TO_SELECTION_CORNER: () => import_Box2d.ROTATE_CORNER_TO_SELECTION_CORNER,
SIN: () => import_utils.SIN,
TAU: () => import_utils.TAU,
Vec2d: () => import_Vec2d.Vec2d,
angleDelta: () => import_utils.angleDelta,
approximately: () => import_utils.approximately,
areAnglesCompatible: () => import_utils.areAnglesCompatible,
canonicalizeRotation: () => import_utils.canonicalizeRotation,
clamp: () => import_utils.clamp,
clampRadians: () => import_utils.clampRadians,
decomposeMatrix2d: () => import_Matrix2d.decomposeMatrix2d,
degreesToRadians: () => import_utils.degreesToRadians,
flipSelectionHandleX: () => import_Box2d.flipSelectionHandleX,
flipSelectionHandleY: () => import_Box2d.flipSelectionHandleY,
getArcLength: () => import_utils.getArcLength,
getDrawLinePathData: () => import_polygon_helpers.getDrawLinePathData,
getHeight: () => import_utils.getHeight,
getMaxX: () => import_utils.getMaxX,
getMaxY: () => import_utils.getMaxY,
getMidX: () => import_utils.getMidX,
getMidY: () => import_utils.getMidY,
getMinX: () => import_utils.getMinX,
getMinY: () => import_utils.getMinY,
getPointOnCircle: () => import_utils.getPointOnCircle,
getPolygonVertices: () => import_utils.getPolygonVertices,
getRoundedInkyPolygonPath: () => import_polygon_helpers.getRoundedInkyPolygonPath,
getRoundedPolygonPoints: () => import_polygon_helpers.getRoundedPolygonPoints,
getStarBounds: () => import_utils.getStarBounds,
getStroke: () => import_getStroke.getStroke,
getStrokeOutlinePoints: () => import_getStrokeOutlinePoints.getStrokeOutlinePoints,
getStrokePoints: () => import_getStrokePoints.getStrokePoints,
getSweep: () => import_utils.getSweep,
getWidth: () => import_utils.getWidth,
intersectCircleCircle: () => import_intersect.intersectCircleCircle,
intersectCirclePolygon: () => import_intersect.intersectCirclePolygon,
intersectCirclePolyline: () => import_intersect.intersectCirclePolyline,
intersectLineSegmentCircle: () => import_intersect.intersectLineSegmentCircle,
intersectLineSegmentLineSegment: () => import_intersect.intersectLineSegmentLineSegment,
intersectLineSegmentPolygon: () => import_intersect.intersectLineSegmentPolygon,
intersectLineSegmentPolyline: () => import_intersect.intersectLineSegmentPolyline,
intersectPolygonBounds: () => import_intersect.intersectPolygonBounds,
intersectPolygonPolygon: () => import_intersect.intersectPolygonPolygon,
isAngleBetween: () => import_utils.isAngleBetween,
isSafeFloat: () => import_utils.isSafeFloat,
isSelectionCorner: () => import_Box2d.isSelectionCorner,
lerpAngles: () => import_utils.lerpAngles,
linesIntersect: () => import_intersect.linesIntersect,
longAngleDist: () => import_utils.longAngleDist,
perimeterOfEllipse: () => import_utils.perimeterOfEllipse,
pointInBounds: () => import_utils.pointInBounds,
pointInCircle: () => import_utils.pointInCircle,
pointInEllipse: () => import_utils.pointInEllipse,
pointInPolygon: () => import_utils.pointInPolygon,
pointInPolyline: () => import_utils.pointInPolyline,
pointInRect: () => import_utils.pointInRect,
pointNearToLineSegment: () => import_utils.pointNearToLineSegment,
pointNearToPolyline: () => import_utils.pointNearToPolyline,
polygonsIntersect: () => import_intersect.polygonsIntersect,
radiansToDegrees: () => import_utils.radiansToDegrees,
rangeIntersection: () => import_utils.rangeIntersection,
rangesOverlap: () => import_utils.rangesOverlap,
rotateSelectionHandle: () => import_Box2d.rotateSelectionHandle,
setStrokePointRadii: () => import_setStrokePointRadii.setStrokePointRadii,
shortAngleDist: () => import_utils.shortAngleDist,
simplify: () => import_utils.simplify,
simplify2: () => import_utils.simplify2,
snapAngle: () => import_utils.snapAngle,
toDomPrecision: () => import_utils.toDomPrecision,
toFixed: () => import_utils.toFixed,
toPrecision: () => import_utils.toPrecision
});
module.exports = __toCommonJS(src_exports);
__reExport(src_exports, require("./lib"), module.exports);
var import_Box2d = require("./lib/Box2d");
var import_CubicSegment2d = require("./lib/CubicSegment2d");
var import_CubicSpline2d = require("./lib/CubicSpline2d");
var import_LineSegment2d = require("./lib/LineSegment2d");
var import_Matrix2d = require("./lib/Matrix2d");
var import_Polyline2d = require("./lib/Polyline2d");
var import_Vec2d = require("./lib/Vec2d");
var import_easings = require("./lib/easings");
var import_getStroke = require("./lib/freehand/getStroke");
var import_getStrokeOutlinePoints = require("./lib/freehand/getStrokeOutlinePoints");
var import_getStrokePoints = require("./lib/freehand/getStrokePoints");
var import_setStrokePointRadii = require("./lib/freehand/setStrokePointRadii");
var import_intersect = require("./lib/intersect");
var import_polygon_helpers = require("./lib/polygon-helpers");
var import_utils = require("./lib/utils");
//# sourceMappingURL=index.js.map

@@ -29,3 +29,3 @@ "use strict";

areAnglesCompatible: () => areAnglesCompatible,
canolicalizeRotation: () => canolicalizeRotation,
canonicalizeRotation: () => canonicalizeRotation,
clamp: () => clamp,

@@ -48,2 +48,3 @@ clampRadians: () => clampRadians,

isAngleBetween: () => isAngleBetween,
isSafeFloat: () => isSafeFloat,
lerpAngles: () => lerpAngles,

@@ -68,2 +69,3 @@ longAngleDist: () => longAngleDist,

toDomPrecision: () => toDomPrecision,
toFixed: () => toFixed,
toPrecision: () => toPrecision

@@ -95,3 +97,3 @@ });

}
function canolicalizeRotation(a) {
function canonicalizeRotation(a) {
a = a % PI2;

@@ -397,2 +399,8 @@ if (a < 0) {

}
function toFixed(v) {
return +v.toFixed(2);
}
const isSafeFloat = (n) => {
return Math.abs(n) < Number.MAX_SAFE_INTEGER;
};
//# sourceMappingURL=utils.js.map

18

package.json
{
"name": "@tldraw/primitives",
"description": "A tiny little drawing app (primitives).",
"version": "2.0.0-canary.83893aac7",
"version": "2.0.0-canary.83a391b46bff",
"packageManager": "yarn@3.5.0",
"author": {

@@ -34,13 +35,13 @@ "name": "tldraw GB Ltd.",

"scripts": {
"test": "yarn run -T jest",
"test:coverage": "yarn run -T jest --coverage",
"build": "echo 'build should be run by turbo'",
"build:package": "yarn run -T tsx ../../scripts/build-package.ts",
"build:api": "yarn run -T tsx ../../scripts/build-api.ts",
"test": "lazy inherit",
"test-coverage": "lazy inherit",
"build": "yarn run -T tsx ../../scripts/build-package.ts",
"build-api": "yarn run -T tsx ../../scripts/build-api.ts",
"prepack": "yarn run -T tsx ../../scripts/prepack.ts",
"postpack": "../../scripts/postpack.sh",
"pack-tarball": "yarn pack",
"lint": "yarn run -T tsx ../../scripts/lint.ts"
},
"dependencies": {
"@tldraw/tlschema": "2.0.0-canary.83893aac7"
"@tldraw/tlschema": "2.0.0-canary.83a391b46bff"
},

@@ -56,2 +57,5 @@ "jest": {

},
"devDependencies": {
"lazyrepo": "0.0.0-alpha.27"
},
"module": "dist-esm/index.mjs",

@@ -58,0 +62,0 @@ "source": "src/index.ts",

# @tldraw/primitives
## License
The source code in this repository (as well as our 2.0+ distributions and releases) are currently licensed under Apache-2.0. These licenses are subject to change in our upcoming 2.0 release. If you are planning to use tldraw in a commercial product, please reach out at [hello@tldraw.com](mailto://hello@tldraw.com).

@@ -1,1 +0,98 @@

export * from './lib'
export {
Box2d,
ROTATE_CORNER_TO_SELECTION_CORNER,
flipSelectionHandleX,
flipSelectionHandleY,
isSelectionCorner,
rotateSelectionHandle,
type RotateCorner,
type SelectionCorner,
type SelectionEdge,
type SelectionHandle,
} from './lib/Box2d'
export { CubicSegment2d, type CubicSegment2dModel } from './lib/CubicSegment2d'
export { CubicSpline2d } from './lib/CubicSpline2d'
export { LineSegment2d, type LineSegment2dModel } from './lib/LineSegment2d'
export {
Matrix2d,
decomposeMatrix2d,
type MatLike,
type Matrix2dModel,
type MatrixInfo,
} from './lib/Matrix2d'
export { Polyline2d } from './lib/Polyline2d'
export { Vec2d, type VecLike } from './lib/Vec2d'
export { EASINGS, type EasingType } from './lib/easings'
export { getStroke } from './lib/freehand/getStroke'
export { getStrokeOutlinePoints } from './lib/freehand/getStrokeOutlinePoints'
export { getStrokePoints } from './lib/freehand/getStrokePoints'
export { setStrokePointRadii } from './lib/freehand/setStrokePointRadii'
export { type StrokeOptions, type StrokePoint } from './lib/freehand/types'
export {
intersectCircleCircle,
intersectCirclePolygon,
intersectCirclePolyline,
intersectLineSegmentCircle,
intersectLineSegmentLineSegment,
intersectLineSegmentPolygon,
intersectLineSegmentPolyline,
intersectPolygonBounds,
intersectPolygonPolygon,
linesIntersect,
polygonsIntersect,
} from './lib/intersect'
export {
getDrawLinePathData,
getRoundedInkyPolygonPath,
getRoundedPolygonPoints,
} from './lib/polygon-helpers'
export {
EPSILON,
PI,
PI2,
SIN,
TAU,
angleDelta,
approximately,
areAnglesCompatible,
canonicalizeRotation,
clamp,
clampRadians,
degreesToRadians,
getArcLength,
getHeight,
getMaxX,
getMaxY,
getMidX,
getMidY,
getMinX,
getMinY,
getPointOnCircle,
getPolygonVertices,
getStarBounds,
getSweep,
getWidth,
isAngleBetween,
isSafeFloat,
lerpAngles,
longAngleDist,
perimeterOfEllipse,
pointInBounds,
pointInCircle,
pointInEllipse,
pointInPolygon,
pointInPolyline,
pointInRect,
pointNearToLineSegment,
pointNearToPolyline,
radiansToDegrees,
rangeIntersection,
rangesOverlap,
shortAngleDist,
simplify,
simplify2,
snapAngle,
toDomPrecision,
toFixed,
toPrecision,
} from './lib/utils'

@@ -107,4 +107,2 @@ import { Vec2d } from '../Vec2d'

// console.log(nextDpr)
if (nextDpr > -0.62 && totalLength - strokePoint.runningLength > strokePoint.radius) {

@@ -111,0 +109,0 @@ // Draw a "soft" corner

@@ -91,3 +91,3 @@ import { Box2d } from './Box2d'

*/
export function canolicalizeRotation(a: number) {
export function canonicalizeRotation(a: number) {
a = a % PI2

@@ -671,1 +671,16 @@ if (a < 0) {

}
/**
* @public
*/
export function toFixed(v: number) {
return +v.toFixed(2)
}
/**
* Check if a float is safe to use. ie: Not too big or small.
* @public
*/
export const isSafeFloat = (n: number) => {
return Math.abs(n) < Number.MAX_SAFE_INTEGER
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet