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 2.0.0-canary.8e8a9be32 to 2.0.0-canary.8ebeb72ef0ea

dist-cjs/lib/polygon-helpers.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 @@

@@ -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;

@@ -384,2 +385,5 @@ static FromPoints(points: VecLike[]): Box2d;

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

@@ -419,2 +423,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[];
/**

@@ -579,2 +589,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 */

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

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

@@ -977,0 +998,0 @@ *

7

dist-cjs/index.js

@@ -46,2 +46,3 @@ "use strict";

getArcLength: () => import_utils.getArcLength,
getDrawLinePathData: () => import_polygon_helpers.getDrawLinePathData,
getHeight: () => import_utils.getHeight,

@@ -56,2 +57,4 @@ getMaxX: () => import_utils.getMaxX,

getPolygonVertices: () => import_utils.getPolygonVertices,
getRoundedInkyPolygonPath: () => import_polygon_helpers.getRoundedInkyPolygonPath,
getRoundedPolygonPoints: () => import_polygon_helpers.getRoundedPolygonPoints,
getStarBounds: () => import_utils.getStarBounds,

@@ -73,2 +76,3 @@ getStroke: () => import_getStroke.getStroke,

isAngleBetween: () => import_utils.isAngleBetween,
isSafeFloat: () => import_utils.isSafeFloat,
isSelectionCorner: () => import_Box2d.isSelectionCorner,

@@ -98,2 +102,3 @@ lerpAngles: () => import_utils.lerpAngles,

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

@@ -114,5 +119,5 @@ });

var import_setStrokePointRadii = require("./lib/freehand/setStrokePointRadii");
var import_types = require("./lib/freehand/types");
var import_intersect = require("./lib/intersect");
var import_polygon_helpers = require("./lib/polygon-helpers");
var import_utils = require("./lib/utils");
//# sourceMappingURL=index.js.map

@@ -274,2 +274,13 @@ "use strict";

}
union(box) {
const minX = Math.min(this.minX, box.x);
const minY = Math.min(this.minY, box.y);
const maxX = Math.max(this.maxX, box.w + box.x);
const maxY = Math.max(this.maxY, box.h + box.y);
this.x = minX;
this.y = minY;
this.width = maxX - minX;
this.height = maxY - minY;
return this;
}
static From(box) {

@@ -276,0 +287,0 @@ return new Box2d(box.x, box.y, box.w, box.h);

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

const { a, b, c, d } = this.values;
if (t <= 0)
return import_Vec2d.Vec2d.From(a);
if (t >= 1)
return import_Vec2d.Vec2d.From(d);
return new import_Vec2d.Vec2d(

@@ -46,0 +50,0 @@ (1 - t) * (1 - t) * (1 - t) * a.x + 3 * ((1 - t) * (1 - t)) * t * b.x + 3 * (1 - t) * (t * t) * c.x + t * t * t * d.x,

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

const { a, b } = this.values;
if (t <= 0)
return import_Vec2d.Vec2d.From(a);
if (t >= 1)
return import_Vec2d.Vec2d.From(b);
return import_Vec2d.Vec2d.Lrp(a, b, t);

@@ -58,0 +62,0 @@ }

@@ -47,2 +47,3 @@ "use strict";

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

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

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

@@ -395,2 +397,8 @@ });

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

20

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

@@ -35,12 +36,12 @@ "name": "tldraw GB Ltd.",

"test": "lazy inherit",
"test:coverage": "lazy inherit",
"build:package": "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",
"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"
"lint": "yarn run -T tsx ../../scripts/lint.ts"
},
"dependencies": {
"@tldraw/tlschema": "2.0.0-canary.8e8a9be32"
"@tldraw/tlschema": "2.0.0-canary.8ebeb72ef0ea"
},

@@ -57,4 +58,3 @@ "jest": {

"devDependencies": {
"benchmark": "^2.1.4",
"lazyrepo": "0.0.0-alpha.12"
"lazyrepo": "0.0.0-alpha.27"
},

@@ -61,0 +61,0 @@ "module": "dist-esm/index.mjs",

# @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).

@@ -45,2 +45,7 @@ export {

export {
getDrawLinePathData,
getRoundedInkyPolygonPath,
getRoundedPolygonPoints,
} from './lib/polygon-helpers'
export {
EPSILON,

@@ -72,2 +77,3 @@ PI,

isAngleBetween,
isSafeFloat,
lerpAngles,

@@ -92,3 +98,4 @@ longAngleDist,

toDomPrecision,
toFixed,
toPrecision,
} from './lib/utils'

@@ -315,2 +315,16 @@ import { Box2dModel } from '@tldraw/tlschema'

union(box: Box2dModel) {
const minX = Math.min(this.minX, box.x)
const minY = Math.min(this.minY, box.y)
const maxX = Math.max(this.maxX, box.w + box.x)
const maxY = Math.max(this.maxY, box.h + box.y)
this.x = minX
this.y = minY
this.width = maxX - minX
this.height = maxY - minY
return this
}
static From(box: Box2dModel) {

@@ -317,0 +331,0 @@ return new Box2d(box.x, box.y, box.w, box.h)

@@ -34,5 +34,5 @@ import { CubicSegment2d } from './CubicSegment2d'

it(`has the expected normals`, () => {
expect(b.getNormal(0)).toMatchObject({ x: -1, y: -0 })
expect(b.getNormal(0)).toMatchObject({ x: -1, y: 0 })
expect(b.getNormal(0.5)).toMatchObject({ x: -0, y: 1 })
expect(b.getNormal(1)).toMatchObject({ x: 1, y: -0 })
expect(b.getNormal(1)).toMatchObject({ x: 1, y: 0 })
})

@@ -39,0 +39,0 @@

@@ -37,2 +37,5 @@ import { BaseSegment2d } from './BaseSegment2d'

if (t <= 0) return Vec2d.From(a)
if (t >= 1) return Vec2d.From(d)
return new Vec2d(

@@ -39,0 +42,0 @@ (1 - t) * (1 - t) * (1 - t) * a.x +

@@ -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

@@ -50,2 +50,5 @@ import { BaseSegment2d } from './BaseSegment2d'

if (t <= 0) return Vec2d.From(a)
if (t >= 1) return Vec2d.From(b)
return Vec2d.Lrp(a, b, t)

@@ -52,0 +55,0 @@ }

@@ -670,1 +670,16 @@ import { Box2d } from './Box2d'

}
/**
* @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

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

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