New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@freesewing/core

Package Overview
Dependencies
Maintainers
2
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@freesewing/core - npm Package Compare versions

Comparing version
4.4.3
to
4.5.0
+1
-1
about.json
{
"id": "core",
"description": "A library for creating made-to-measure sewing patterns",
"version": "4.4.3"
"version": "4.5.0"
}
{
"name": "@freesewing/core",
"version": "4.4.3",
"version": "4.5.0",
"description": "A library for creating made-to-measure sewing patterns",

@@ -45,3 +45,3 @@ "author": "Joost De Cock <joost@joost.at> (https://codeberg.org/joostdecock)",

"dependencies": {
"@freesewing/core-plugins": "4.4.3",
"@freesewing/core-plugins": "4.5.0",
"bezier-js": "6.1.4",

@@ -48,0 +48,0 @@ "hooks": "0.3.2",

@@ -14,3 +14,3 @@ <p align='center'><a

title="All Contributors"
><img src="https://img.shields.io/badge/all_contributors-132-pink.svg"
><img src="https://img.shields.io/badge/all_contributors-131-pink.svg"
alt="All Contributors"/>

@@ -17,0 +17,0 @@ </a></p><p align='center'><a

@@ -129,2 +129,4 @@ import { Bezier } from './bezier.mjs'

Part.prototype.shorthand = function () {
// We'll need this
let self = this
const complete = this.context.settings?.complete ? true : false

@@ -144,3 +146,25 @@ const expand = this.context.settings?.expand ? true : false

scale: this.context.settings?.scale,
store: this.context.store,
store: this.context.store.extend([
// Add prefixed getter
[
'pget',
function (s, path, dflt) {
const prefix = self.context.settings.options.storePrefix
? self.context.settings.options.storePrefix
: self.context.store.activePart + '.'
const val = self.context.store.get(path, dflt, prefix)
return self.context.store.get(path, dflt, prefix)
},
],
// Add prefixed setter
[
'pset',
function (s, path, value) {
const prefix = self.context.settings.options.storePrefix
? self.context.settings.options.storePrefix
: self.context.store.activePart + '.'
return self.context.store.set(path, value, prefix)
},
],
]),
units: this.__unitsClosure(),

@@ -150,4 +174,2 @@ utils: utils,

}
// We'll need this
let self = this

@@ -192,6 +214,12 @@ // Wrap the Point constructor so objects can log

shorthand.options = new Proxy(this.context.settings.options, {
get: function (options, name) {
if (typeof options[name] === 'undefined')
self.context.store.log.warn(`Tried to access \`options.${name}\` but it is \`undefined\``)
return Reflect.get(...arguments)
get: function (options, name, receiver) {
// Part-scoped options take precedence
const prefixedName = self.context.store.activePart.replace('.', '_') + '_' + name
if (typeof options[prefixedName] === 'undefined') {
if (typeof options[name] === 'undefined') {
self.context.store.log.warn(`Tried to access \`options.${name}\` but it is \`undefined\``)
}
return Reflect.get(...arguments)
}
return options[prefixedName]
},

@@ -210,3 +238,2 @@ set: (options, name, value) => (self.context.settings.options[name] = value),

})
// Macro closure at the end as it includes the shorthand object

@@ -213,0 +240,0 @@ shorthand.macro = this.__macroClosure(shorthand)

@@ -77,6 +77,3 @@ import { Attributes } from '../attributes.mjs'

this.designConfig.parts.push(part)
if (resolveImmediately) {
if (this.__configResolver.addPart(part) && typeof this.draftQueue !== 'undefined')
this.draftQueue.addPart(part.name)
} else this.__initialized = false
if (resolveImmediately) this.__configResolver.addPart(part)
}

@@ -83,0 +80,0 @@ return this

@@ -337,3 +337,3 @@ import { __addNonEnumProp } from '../utils.mjs'

const depTypes = ['from', 'after']
// the two lists of special istructions
// the two lists of special instructions
const exceptionTypes = ['never', 'always']

@@ -340,0 +340,0 @@ /**

@@ -1,2 +0,1 @@

import { PatternDraftQueue } from './pattern-draft-queue.mjs'
import { Part } from '../part.mjs'

@@ -19,3 +18,2 @@ import { __macroName, getSnappedPercentageValue, mergeOptions } from '../utils.mjs'

PatternDrafter.prototype.draft = function () {
this.pattern.draftQueue = new PatternDraftQueue(this.pattern)
this.pattern.__runHooks('preDraft')

@@ -42,7 +40,4 @@ // Keep container for drafted parts fresh

this.__loadAbsoluteOptionsSet(set)
// draft all the parts for this set
this.pattern.draftQueue.start()
while (this.pattern.draftQueue.hasNext()) {
const partName = this.pattern.draftQueue.next()
for (const partName of this.pattern.config.draftOrder) {
if (this.pattern.__needs(partName, set)) {

@@ -49,0 +44,0 @@ this.draftPartForSet(partName, set)

@@ -108,3 +108,3 @@ import { Attributes } from './attributes.mjs'

* @param {Point} that - The Point instance to calculate the distance to
* @return {float} distance - The distance between this Point and that Point
* @return {number} distance - The distance between this Point and that Point
*/

@@ -115,3 +115,3 @@ Point.prototype.dist = function (that) {

return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2))
return Math.hypot(dx, dy)
}

@@ -118,0 +118,0 @@

@@ -149,5 +149,7 @@ import set from 'lodash.set'

* @param {mixed} dflt - Default method to return if key is undefined
* @param {string|array} prefix - A prefix to apply to the path to the key
* @return {mixed} value - The value stored under key
*/
Store.prototype.get = function (path, dflt) {
Store.prototype.get = function (path, dflt, prefix = '') {
path = prefixStorePath(prefix, path)
const val = get(this, path, dflt)

@@ -184,5 +186,7 @@ if (typeof val === 'undefined') {

* @param {mixed} value - The value to set
* @param {string|array} prefix - A prefix to apply to the path to the key
* @return {Store} this - The Store instance
*/
Store.prototype.set = function (path, value) {
Store.prototype.set = function (path, value, prefix) {
path = prefixStorePath(prefix, path)
if (typeof value === 'undefined') {

@@ -201,5 +205,7 @@ this.log.warn(`Store.set(value) on key \`${path}\`, but value is undefined`)

* @param {mixed} value - The value to set
* @param {string|array} prefix - A prefix to apply to the path to the key
* @return {Store} this - The Store instance
*/
Store.prototype.setIfUnset = function (path, value) {
Store.prototype.setIfUnset = function (path, value, prefix = '') {
path = prefixStorePath(prefix, path)
if (typeof value === 'undefined') {

@@ -220,6 +226,7 @@ this.log.warn(`Store.setIfUnset(value) on key \`${path}\`, but value is undefined`)

* @param {mixed} value - The value to set
* @param {string|array} prefix - A prefix to apply to the path to the key
* @return {Store} this - The Store instance
*/
Store.prototype.unset = function (path) {
unset(this, path)
Store.prototype.unset = function (path, prefix = '') {
unset(this, prefixStorePath(prefix, path))

@@ -246,1 +253,21 @@ return this

}
/**
* Applies a prefix to a store path
*
* @param {string|array} prefix - The prefix to apply
* @param {string|array} path - The path
* @return {string|array} prefixedPath - The prefixed path
*/
function prefixStorePath(prefix, path) {
if (!prefix) return path
if (Array.isArray(path)) {
if (Array.isArray(prefix)) path = [...prefix, ...path]
else path = [prefix, ...path]
} else {
if (Array.isArray(prefix)) path = prefix.join('.') + path
else path = prefix + path
}
return path
}

@@ -120,3 +120,3 @@ import { Attributes } from './attributes.mjs'

Svg.prototype.__escapeText = function (text) {
if (Array.isArray(text)) return text.map((t) => t.replace(/"/g, '&#8220;')).join(' ')
if (Array.isArray(text)) return text.map((t) => (t ? t.replace(/"/g, '&#8220;') : '')).join(' ')
return text.replace(/"/g, '&#8220;')

@@ -123,0 +123,0 @@ }

@@ -428,3 +428,5 @@ import { Bezier } from './bezier.mjs'

let snapConf = conf.snap
if (!Array.isArray(snapConf) && snapConf.metric && snapConf.imperial) snapConf = snapConf[units]
if (!Array.isArray(snapConf) && snapConf.metric && snapConf.imperial) {
snapConf = units === 'imperial' ? snapConf.imperial : snapConf.metric
}
// Simple steps

@@ -711,3 +713,3 @@ if (typeof snapConf === 'number') return Math.round(abs / snapConf) * snapConf

* @param {float} precision - How precise we should check
* @return {bool} result - True of the Point is on the line segment, false when not
* @return {boolean} result - True if the Point is on the line segment, false when not
*/

@@ -718,4 +720,3 @@ export function pointOnLine(from, to, check, precision = 1e6) {

let lenB = from.dist(check) + check.dist(to)
if (Math.round(lenA) == Math.round(lenB)) return true
else return false
return Math.round(Math.abs(lenA - lenB) * precision) === 0
}

@@ -722,0 +723,0 @@

/**
* A queue for handling the draft order of pattern parts
* Unlike most queues, traversing this queue is non-destructive
* so that the queue can be traversed many times.
* The goal is to allow the queue to be manipulated while being traversed
* @class
* @param {Pattern} pattern the pattern that will use the queue
*/
export function PatternDraftQueue(pattern) {
// save the config resolver
this.__configResolver = pattern.__configResolver
// get the draft order in its current state
this.queue = this.__resolveDraftOrder()
// start at 0
this.start()
}
/** Go back to the beginning of the queue */
PatternDraftQueue.prototype.start = function () {
this.queueIndex = 0
}
/**
* Add a part to end of the queue. Useful for queueing up parts a draft time
* @param {string} partName the name to the part to add
*/
PatternDraftQueue.prototype.addPart = function (partName) {
if (!this.contains(partName)) this.queue.push(partName)
return this
}
/**
* Check whether the queue has a next part without moving the queue index
* @return {Boolean} whether there is a next part in the queue
*/
PatternDraftQueue.prototype.hasNext = function () {
return this.queueIndex < this.queue.length
}
/**
* Get the next part in the queue without moving the queue index
* @return {string} the next part in the queue
*/
PatternDraftQueue.prototype.peek = function () {
return this.queue[this.queueIndex]
}
/**
* Get the next part in the queue and move the queue index
* @return {string} the next part in the queue
*/
PatternDraftQueue.prototype.next = function () {
const next = this.peek()
this.queueIndex++
return next
}
/**
* Check whether a part is already queued
* @param {string} partName the name of the part
* @return {boolean} whether the part is in the queue
*/
PatternDraftQueue.prototype.contains = function (partName) {
return this.queue.indexOf(partName) !== -1
}
/**
* Resolves the draft order based on the configuation
* @private
* @return A list of parts in the order they should be drafted
*/
PatternDraftQueue.prototype.__resolveDraftOrder = function () {
const partDistances = this.__configResolver.__mutated.partDistance
return Object.keys(this.__configResolver.parts).sort(
(p1, p2) => partDistances[p2] - partDistances[p1]
)
}