1
0
Fork 0

use presets for common hide configurations

This commit is contained in:
Enoch Riese 2023-03-08 12:12:13 -06:00
parent 0c501f642d
commit 7551f09b8d
33 changed files with 228 additions and 170 deletions

View file

@ -1,5 +1,6 @@
import { pluginBust } from '@freesewing/plugin-bust' import { pluginBust } from '@freesewing/plugin-bust'
import { front as carltonFront } from '@freesewing/carlton' import { front as carltonFront } from '@freesewing/carlton'
import { hidePresets } from '@freesewing/core'
function draftCarlitaFront({ function draftCarlitaFront({
paperless, paperless,
@ -501,10 +502,7 @@ function draftCarlitaFront({
export const front = { export const front = {
name: 'carlita.front', name: 'carlita.front',
from: carltonFront, from: carltonFront,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['highBust', 'bustSpan', 'hpsToBust'], measurements: ['highBust', 'bustSpan', 'hpsToBust'],
plugins: [pluginBust], plugins: [pluginBust],
options: { options: {

View file

@ -1,5 +1,6 @@
import { back as bentBack } from '@freesewing/bent' import { back as bentBack } from '@freesewing/bent'
import { calculateRatios } from './shared.mjs' import { calculateRatios } from './shared.mjs'
import { hidePresets } from '@freesewing/core'
function draftCarltonBack({ function draftCarltonBack({
paperless, paperless,
@ -230,10 +231,7 @@ function draftCarltonBack({
export const back = { export const back = {
name: 'carlton.back', name: 'carlton.back',
from: bentBack, from: bentBack,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['chest', 'hpsToWaistBack'], measurements: ['chest', 'hpsToWaistBack'],
options: { options: {
backPleat: 0.048, backPleat: 0.048,

View file

@ -1,5 +1,6 @@
import { front as bentFront } from '@freesewing/bent' import { front as bentFront } from '@freesewing/bent'
import { calculateRatios } from './shared.mjs' import { calculateRatios } from './shared.mjs'
import { hidePresets } from '@freesewing/core'
function draftCarltonFront({ function draftCarltonFront({
paperless, paperless,
@ -477,10 +478,7 @@ function draftCarltonFront({
export const front = { export const front = {
name: 'carlton.front', name: 'carlton.front',
from: bentFront, from: bentFront,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['waist', 'waistToFloor', 'waistToSeat'], measurements: ['waist', 'waistToFloor', 'waistToSeat'],
options: { options: {
chestEase: { pct: 10, min: 5, max: 20, menu: 'fit' }, chestEase: { pct: 10, min: 5, max: 20, menu: 'fit' },

View file

@ -1,5 +1,6 @@
import { back as titanBack } from '@freesewing/titan' import { back as titanBack } from '@freesewing/titan'
import { front } from './front.mjs' import { front } from './front.mjs'
import { hidePresets } from '@freesewing/core'
function draftCharlieBack({ function draftCharlieBack({
points, points,
@ -346,10 +347,7 @@ export const back = {
name: 'charlie.back', name: 'charlie.back',
from: titanBack, from: titanBack,
after: front, after: front,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { options: {
backPocketVerticalPlacement: { pct: 24, min: 18, max: 30, menu: 'pockets.backpockets' }, backPocketVerticalPlacement: { pct: 24, min: 18, max: 30, menu: 'pockets.backpockets' },
backPocketHorizontalPlacement: { pct: 55, min: 48, max: 62, menu: 'pockets.backpockets' }, backPocketHorizontalPlacement: { pct: 55, min: 48, max: 62, menu: 'pockets.backpockets' },

View file

@ -1,5 +1,5 @@
import { elastics } from '@freesewing/snapseries' import { elastics } from '@freesewing/snapseries'
import { pctBasedOn } from '@freesewing/core' import { pctBasedOn, hidePresets } from '@freesewing/core'
import { front as titanFront } from '@freesewing/titan' import { front as titanFront } from '@freesewing/titan'
function draftCharlieFront({ function draftCharlieFront({
@ -366,10 +366,7 @@ function draftCharlieFront({
export const front = { export const front = {
name: 'charlie.front', name: 'charlie.front',
from: titanFront, from: titanFront,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: [ measurements: [
'crossSeam', 'crossSeam',
'crossSeamFront', 'crossSeamFront',

View file

@ -1,5 +1,6 @@
import { front as frontBase } from '@freesewing/brian' import { front as frontBase } from '@freesewing/brian'
import { back as backBase } from '@freesewing/brian' import { back as backBase } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
export function draftDianaFrontOrBack({ export function draftDianaFrontOrBack({
measurements, measurements,
@ -165,10 +166,7 @@ export function draftDianaFrontOrBack({
export const front = { export const front = {
name: 'diana.front', name: 'diana.front',
from: frontBase, from: frontBase,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: [ measurements: [
'biceps', 'biceps',
'chest', 'chest',
@ -244,10 +242,7 @@ export const front = {
export const back = { export const back = {
name: 'diana.back', name: 'diana.back',
from: backBase, from: backBase,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: [ measurements: [
'biceps', 'biceps',
'chest', 'chest',

View file

@ -1,6 +1,7 @@
import { sleeve as sleeveBase } from '@freesewing/brian' import { sleeve as sleeveBase } from '@freesewing/brian'
import { front } from './front.mjs' import { front } from './front.mjs'
import { back } from './front.mjs' import { back } from './front.mjs'
import { hidePresets } from '@freesewing/core'
function draftDianaSleeve({ sa, points, paths, Path, complete, paperless, macro, part }) { function draftDianaSleeve({ sa, points, paths, Path, complete, paperless, macro, part }) {
paths.seam = new Path() paths.seam = new Path()
@ -67,9 +68,6 @@ export const sleeve = {
name: 'diana.sleeve', name: 'diana.sleeve',
from: sleeveBase, from: sleeveBase,
after: [front, back], after: [front, back],
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
draft: draftDianaSleeve, draft: draftDianaSleeve,
} }

View file

@ -1,5 +1,6 @@
import { sleeve as brianSleeve } from '@freesewing/brian' import { sleeve as brianSleeve } from '@freesewing/brian'
import { back } from './back.mjs' import { back } from './back.mjs'
import { hidePresets } from '@freesewing/core'
function draftHueySleeve({ function draftHueySleeve({
Point, Point,
@ -94,8 +95,5 @@ export const sleeve = {
from: brianSleeve, from: brianSleeve,
after: back, after: back,
draft: draftHueySleeve, draft: draftHueySleeve,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
} }

View file

@ -1,5 +1,6 @@
import { back as brianBack } from '@freesewing/brian' import { back as brianBack } from '@freesewing/brian'
import { front } from './front.mjs' import { front } from './front.mjs'
import { hidePresets } from '@freesewing/core'
function hugoBack({ function hugoBack({
store, store,
@ -116,10 +117,7 @@ function hugoBack({
export const back = { export const back = {
name: 'hugo.back', name: 'hugo.back',
from: brianBack, from: brianBack,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['hips'], measurements: ['hips'],
after: front, after: front,
draft: hugoBack, draft: hugoBack,

View file

@ -1,4 +1,5 @@
import { front as brianFront } from '@freesewing/brian' import { front as brianFront } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
import { import {
collarEase, collarEase,
armholeDepthFactor, armholeDepthFactor,
@ -189,10 +190,7 @@ function hugoFront({
export const front = { export const front = {
name: 'hugo.front', name: 'hugo.front',
from: brianFront, from: brianFront,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['hips', 'waistToHips'], measurements: ['hips', 'waistToHips'],
options: { options: {
collarEase, collarEase,

View file

@ -2,6 +2,7 @@ import { sleeve as brianSleeve } from '@freesewing/brian'
import { front } from './front.mjs' import { front } from './front.mjs'
import { back } from './back.mjs' import { back } from './back.mjs'
import { cuffEase, sleeveLengthBonus, ribbingHeight } from './options.mjs' import { cuffEase, sleeveLengthBonus, ribbingHeight } from './options.mjs'
import { hidePresets } from '@freesewing/core'
function hugoSleeve({ function hugoSleeve({
utils, utils,
@ -223,10 +224,7 @@ function hugoSleeve({
export const sleeve = { export const sleeve = {
name: 'hugo.sleeve', name: 'hugo.sleeve',
from: brianSleeve, from: brianSleeve,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
after: [front, back], after: [front, back],
options: { cuffEase, sleeveLengthBonus, ribbingHeight }, options: { cuffEase, sleeveLengthBonus, ribbingHeight },
draft: hugoSleeve, draft: hugoSleeve,

View file

@ -1,5 +1,6 @@
import { calculateRatios, backSideBoundary } from './shared.mjs' import { calculateRatios, backSideBoundary } from './shared.mjs'
import { back as bentBack } from '@freesewing/bent' import { back as bentBack } from '@freesewing/bent'
import { hidePresets } from '@freesewing/core'
import { import {
centerBackDart, centerBackDart,
hipsEase, hipsEase,
@ -91,11 +92,7 @@ export const backBase = {
name: 'jaeger.backBase', name: 'jaeger.backBase',
measurements: ['hips', 'waist'], measurements: ['hips', 'waist'],
from: bentBack, from: bentBack,
hide: { hide: hidePresets.HIDE_ALL,
self: true,
from: true,
inherited: true,
},
options: { options: {
centerBackDart, centerBackDart,
hipsEase, hipsEase,

View file

@ -1,5 +1,6 @@
import { backSideBoundary } from './shared.mjs' import { backSideBoundary } from './shared.mjs'
import { front as bentFront } from '@freesewing/bent' import { front as bentFront } from '@freesewing/bent'
import { hidePresets } from '@freesewing/core'
import { import {
hipsEase, hipsEase,
waistEase, waistEase,
@ -192,11 +193,7 @@ export const frontBase = {
name: 'jaeger.frontBase', name: 'jaeger.frontBase',
measurements: ['hips', 'waist'], measurements: ['hips', 'waist'],
from: bentFront, from: bentFront,
hide: { hide: hidePresets.HIDE_ALL,
self: true,
from: true,
inherited: true,
},
options: { options: {
hipsEase, hipsEase,
waistEase, waistEase,

View file

@ -1,5 +1,6 @@
import { topSleeve as bentTopSleeve } from '@freesewing/bent' import { topSleeve as bentTopSleeve } from '@freesewing/bent'
import { sleeveVentLength, sleeveVentWidth } from './options.mjs' import { sleeveVentLength, sleeveVentWidth } from './options.mjs'
import { hidePresets } from '@freesewing/core'
function jaegerTopSleeve({ function jaegerTopSleeve({
paperless, paperless,
@ -219,10 +220,7 @@ function jaegerTopSleeve({
export const topSleeve = { export const topSleeve = {
name: 'jaeger.topSleeve', name: 'jaeger.topSleeve',
from: bentTopSleeve, from: bentTopSleeve,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { sleeveVentLength, sleeveVentWidth }, options: { sleeveVentLength, sleeveVentWidth },
draft: jaegerTopSleeve, draft: jaegerTopSleeve,
} }

View file

@ -1,5 +1,6 @@
import { underSleeve as bentUnderSleeve } from '@freesewing/bent' import { underSleeve as bentUnderSleeve } from '@freesewing/bent'
import { sleeveVentLength, sleeveVentWidth } from './options.mjs' import { sleeveVentLength, sleeveVentWidth } from './options.mjs'
import { hidePresets } from '@freesewing/core'
function jaegerUnderSleeve({ function jaegerUnderSleeve({
paperless, paperless,
@ -204,9 +205,6 @@ export const underSleeve = {
name: 'jaeger.underSleeve', name: 'jaeger.underSleeve',
from: bentUnderSleeve, from: bentUnderSleeve,
options: { sleeveVentLength, sleeveVentWidth }, options: { sleeveVentLength, sleeveVentWidth },
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
draft: jaegerUnderSleeve, draft: jaegerUnderSleeve,
} }

View file

@ -1,4 +1,5 @@
import { back as bellaBack } from '@freesewing/bella' import { back as bellaBack } from '@freesewing/bella'
import { hidePresets } from '@freesewing/core'
import * as options from './options.mjs' import * as options from './options.mjs'
function nobleBackPoints({ points, Path, paths, options, snippets, log, part }) { function nobleBackPoints({ points, Path, paths, options, snippets, log, part }) {
@ -83,11 +84,7 @@ function nobleBackPoints({ points, Path, paths, options, snippets, log, part })
export const backPoints = { export const backPoints = {
name: 'noble.backPoints', name: 'noble.backPoints',
from: bellaBack, from: bellaBack,
hide: { hide: hidePresets.HIDE_ALL,
self: true,
from: true,
inherited: true,
},
options, options,
draft: nobleBackPoints, draft: nobleBackPoints,
} }

View file

@ -1,4 +1,5 @@
import { frontSideDart as bellaFront } from '@freesewing/bella' import { frontSideDart as bellaFront } from '@freesewing/bella'
import { hidePresets } from '@freesewing/core'
import * as options from './options.mjs' import * as options from './options.mjs'
function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, part }) { function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro, part }) {
@ -318,11 +319,7 @@ function nobleFrontPoints({ log, points, Path, paths, snippets, options, macro,
export const frontPoints = { export const frontPoints = {
name: 'noble.frontPoints', name: 'noble.frontPoints',
from: bellaFront, from: bellaFront,
hide: { hide: hidePresets.HIDE_ALL,
self: true,
from: true,
inherited: true,
},
options, options,
draft: nobleFrontPoints, draft: nobleFrontPoints,
} }

View file

@ -1,5 +1,5 @@
import { back as titanBack } from '@freesewing/titan' import { back as titanBack } from '@freesewing/titan'
import { pctBasedOn } from '@freesewing/core' import { pctBasedOn, hidePresets } from '@freesewing/core'
import { elastics, smallSteps } from '@freesewing/snapseries' import { elastics, smallSteps } from '@freesewing/snapseries'
function pacoBack({ function pacoBack({
@ -312,10 +312,7 @@ function pacoBack({
export const back = { export const back = {
name: 'paco.back', name: 'paco.back',
from: titanBack, from: titanBack,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['heel'], measurements: ['heel'],
options: { options: {
// Constants // Constants

View file

@ -1,5 +1,6 @@
import { front as titanFront } from '@freesewing/titan' import { front as titanFront } from '@freesewing/titan'
import { back } from './back.mjs' import { back } from './back.mjs'
import { hidePresets } from '@freesewing/core'
function pacoFront({ function pacoFront({
utils, utils,
@ -327,10 +328,7 @@ function pacoFront({
export const front = { export const front = {
name: 'paco.front', name: 'paco.front',
from: titanFront, from: titanFront,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
after: back, after: back,
draft: pacoFront, draft: pacoFront,
} }

View file

@ -1,6 +1,7 @@
import { calculateReduction } from './shared.mjs' import { calculateReduction } from './shared.mjs'
import { flipPlugin } from '@freesewing/plugin-flip' import { flipPlugin } from '@freesewing/plugin-flip'
import { back as brianBack } from '@freesewing/brian' import { back as brianBack } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
import { import {
collarFactor, collarFactor,
backDarts, backDarts,
@ -408,10 +409,7 @@ export const back = {
plugins: [flipPlugin], plugins: [flipPlugin],
measurements: ['waist', 'hips'], measurements: ['waist', 'hips'],
from: brianBack, from: brianBack,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { options: {
collarFactor, collarFactor,
backDarts, backDarts,

View file

@ -1,5 +1,6 @@
import { front } from './front.mjs' import { front } from './front.mjs'
import { sleeve as brianSleeve } from '@freesewing/brian' import { sleeve as brianSleeve } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
import { import {
cuffOverlap, cuffOverlap,
cuffDrape, cuffDrape,
@ -284,10 +285,7 @@ export const sleeve = {
name: 'simon.sleeve', name: 'simon.sleeve',
from: brianSleeve, from: brianSleeve,
after: front, after: front,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { options: {
cuffOverlap, cuffOverlap,
cuffDrape, cuffDrape,

View file

@ -1,4 +1,5 @@
import { front as brianFront, back as brianBack } from '@freesewing/brian' import { front as brianFront, back as brianBack } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
function svenFrontBack({ function svenFrontBack({
store, store,
@ -128,10 +129,7 @@ export const front = {
name: 'sven.front', name: 'sven.front',
from: brianFront, from: brianFront,
options, options,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements, measurements,
draft: svenFrontBack, draft: svenFrontBack,
} }
@ -140,10 +138,7 @@ export const back = {
name: 'sven.back', name: 'sven.back',
from: brianBack, from: brianBack,
options, options,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements, measurements,
draft: svenFrontBack, draft: svenFrontBack,
} }

View file

@ -1,5 +1,6 @@
import { sleeve as brianSleeve } from '@freesewing/brian' import { sleeve as brianSleeve } from '@freesewing/brian'
import { ribbing, front, back } from './frontback.mjs' import { ribbing, front, back } from './frontback.mjs'
import { hidePresets } from '@freesewing/core'
function svenSleeve({ store, sa, points, paths, Path, complete, paperless, macro, options, part }) { function svenSleeve({ store, sa, points, paths, Path, complete, paperless, macro, options, part }) {
if (options.ribbing) { if (options.ribbing) {
@ -72,10 +73,7 @@ function svenSleeve({ store, sa, points, paths, Path, complete, paperless, macro
export const sleeve = { export const sleeve = {
name: 'sven.sleeve', name: 'sven.sleeve',
from: brianSleeve, from: brianSleeve,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
after: [front, back], after: [front, back],
options: { options: {
ribbing, ribbing,

View file

@ -1,4 +1,5 @@
import { base } from '@freesewing/brian' import { base } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
function teaganFront({ function teaganFront({
utils, utils,
@ -166,10 +167,7 @@ export const front = {
name: 'teagan.front', name: 'teagan.front',
from: base, from: base,
measurements: ['hips', 'waist'], measurements: ['hips', 'waist'],
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { options: {
bicepsEase: 0.05, bicepsEase: 0.05,
shoulderEase: 0, shoulderEase: 0,

View file

@ -1,4 +1,5 @@
import { sleevecap } from '@freesewing/brian' import { sleevecap } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
function teaganSleeve({ function teaganSleeve({
sa, sa,
@ -96,10 +97,7 @@ function teaganSleeve({
export const sleeve = { export const sleeve = {
name: 'teagan.sleeve', name: 'teagan.sleeve',
from: sleevecap, from: sleevecap,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { options: {
sleeveEase: { pct: 15, min: 5, max: 35, menu: 'style' }, sleeveEase: { pct: 15, min: 5, max: 35, menu: 'style' },
}, },

View file

@ -1,6 +1,7 @@
import { constructMainDart, shapeSideSeam, dartPath } from './shared.mjs' import { constructMainDart, shapeSideSeam, dartPath } from './shared.mjs'
import { back as brianBack } from '@freesewing/brian' import { back as brianBack } from '@freesewing/brian'
import { backInset, shoulderInset, neckInset, centerBackDart, backScyeDart } from './options.mjs' import { backInset, shoulderInset, neckInset, centerBackDart, backScyeDart } from './options.mjs'
import { hidePresets } from '@freesewing/core'
function wahidBack({ function wahidBack({
points, points,
@ -227,10 +228,7 @@ function wahidBack({
export const back = { export const back = {
name: 'wahid.back', name: 'wahid.back',
from: brianBack, from: brianBack,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['hips', 'waist'], measurements: ['hips', 'waist'],
options: { options: {
backInset, backInset,

View file

@ -1,5 +1,6 @@
import { constructMainDart, shapeSideSeam, dartPath } from './shared.mjs' import { constructMainDart, shapeSideSeam, dartPath } from './shared.mjs'
import { front as brianFront } from '@freesewing/brian' import { front as brianFront } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
import { import {
frontOverlap, frontOverlap,
necklineDrop, necklineDrop,
@ -493,10 +494,7 @@ function wahidFront({
export const front = { export const front = {
name: 'wahid.front', name: 'wahid.front',
from: brianFront, from: brianFront,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
measurements: ['hips', 'waist'], measurements: ['hips', 'waist'],
options: { options: {
frontOverlap, frontOverlap,

View file

@ -1,5 +1,6 @@
import { back as brianBack } from '@freesewing/brian' import { back as brianBack } from '@freesewing/brian'
import { sharedDimensions } from './shared.mjs' import { sharedDimensions } from './shared.mjs'
import { hidePresets } from '@freesewing/core'
function yuriBack({ function yuriBack({
store, store,
@ -109,10 +110,7 @@ export const back = {
sleeveLengthBonus: { pct: 1, min: 0, max: 10 }, sleeveLengthBonus: { pct: 1, min: 0, max: 10 },
}, },
}, },
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { options: {
hipsEase: { pct: 0, min: 0, max: 10 }, hipsEase: { pct: 0, min: 0, max: 10 },
}, },

View file

@ -1,5 +1,6 @@
import { front as brianFront } from '@freesewing/brian' import { front as brianFront } from '@freesewing/brian'
import { sharedDimensions } from './shared.mjs' import { sharedDimensions } from './shared.mjs'
import { hidePresets } from '@freesewing/core'
function yuriFront({ function yuriFront({
store, store,
@ -118,10 +119,7 @@ export const front = {
sleeveLengthBonus: { pct: 1, min: 0, max: 10 }, sleeveLengthBonus: { pct: 1, min: 0, max: 10 },
}, },
}, },
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
options: { options: {
hipsEase: { pct: 0, min: 0, max: 10 }, hipsEase: { pct: 0, min: 0, max: 10 },
}, },

View file

@ -1,4 +1,5 @@
import { sleeve as brianSleeve } from '@freesewing/brian' import { sleeve as brianSleeve } from '@freesewing/brian'
import { hidePresets } from '@freesewing/core'
function yuriSleeve({ Point, Path, points, paths, complete, sa, paperless, macro, part }) { function yuriSleeve({ Point, Path, points, paths, complete, sa, paperless, macro, part }) {
// Clear paths from Brian, but keep sleevecap // Clear paths from Brian, but keep sleevecap
@ -69,9 +70,6 @@ function yuriSleeve({ Point, Path, points, paths, complete, sa, paperless, macro
export const sleeve = { export const sleeve = {
name: 'yuri.sleeve', name: 'yuri.sleeve',
from: brianSleeve, from: brianSleeve,
hide: { hide: hidePresets.HIDE_TREE,
from: true,
inherited: true,
},
draft: yuriSleeve, draft: yuriSleeve,
} }

View file

@ -7,6 +7,7 @@ import { Point } from './point.mjs'
import { Path } from './path.mjs' import { Path } from './path.mjs'
import { Snippet } from './snippet.mjs' import { Snippet } from './snippet.mjs'
import { Store } from './store.mjs' import { Store } from './store.mjs'
import { hidePresets } from './pattern-config.mjs'
import { import {
beamIntersectsCircle, beamIntersectsCircle,
beamIntersectsX, beamIntersectsX,
@ -47,6 +48,8 @@ export {
Store, Store,
version, version,
Bezier, Bezier,
//consts
hidePresets,
// Utils // Utils
beamIntersectsCircle, beamIntersectsCircle,
beamIntersectsX, beamIntersectsX,

View file

@ -1,5 +1,18 @@
import { __addNonEnumProp, capitalize } from './utils.mjs' import { __addNonEnumProp, capitalize } from './utils.mjs'
export const hidePresets = {
HIDE_ALL: {
self: true,
from: true,
after: true,
inherited: true,
},
HIDE_TREE: {
from: true,
inherited: true,
},
}
/** /**
* Get the name of the given plugin config * Get the name of the given plugin config
* *
@ -328,18 +341,21 @@ PatternConfig.prototype.__addPartPlugins = function (part) {
const depTypes = ['from', 'after'] const depTypes = ['from', 'after']
const exceptionTypes = ['never', 'always'] const exceptionTypes = ['never', 'always']
PatternConfig.prototype.__resolvePartHiding = function (part) { PatternConfig.prototype.__resolvePartHiding = function (part) {
if (part.hide) { let hide = part.hide
if (typeof hide === 'string') hide = hidePresets[hide]
if (!hide) return
// get the part's option priority // get the part's option priority
const partDistance = this.__mutated.partDistance?.[part.name] const partDistance = this.__mutated.partDistance?.[part.name]
const neverDistance = this.__hiding.never[part.name] || Infinity const neverDistance = this.__hiding.never[part.name] || Infinity
const alwaysDistance = this.__hiding.always[part.name] || Infinity const alwaysDistance = this.__hiding.always[part.name] || Infinity
if (part.hide.self && (neverDistance > partDistance || alwaysDistance <= neverDistance)) if (hide.self && (neverDistance > partDistance || alwaysDistance <= neverDistance))
this.partHide[part.name] = true this.partHide[part.name] = true
exceptionTypes.forEach((e, i) => { exceptionTypes.forEach((e, i) => {
if (part.hide[e]) { if (hide[e]) {
part.hide[e].forEach((p) => { hide[e].forEach((p) => {
const otherDistance = this.__hiding[exceptionTypes[Math.abs(i - 1)]][p] || Infinity const otherDistance = this.__hiding[exceptionTypes[Math.abs(i - 1)]][p] || Infinity
if (otherDistance > partDistance) { if (otherDistance > partDistance) {
@ -351,11 +367,9 @@ PatternConfig.prototype.__resolvePartHiding = function (part) {
} }
}) })
Object.keys(this.__hiding).forEach((k) => { depTypes.concat('inherited').forEach((k) => {
if (!exceptionTypes.includes(k) && this.__hiding[k][part.name] === undefined) if (this.__hiding[k][part.name] === undefined) this.__hiding[k][part.name] = hide[k]
this.__hiding[k][part.name] = part.hide[k]
}) })
}
} }
/** /**
* Recursively register part dependencies * Recursively register part dependencies

View file

@ -1,5 +1,5 @@
import chai from 'chai' import chai from 'chai'
import { Design } from '../src/index.mjs' import { Design, hidePresets } from '../src/index.mjs'
const expect = chai.expect const expect = chai.expect
function hidePartMatcher(partName) { function hidePartMatcher(partName) {
@ -14,7 +14,25 @@ function hidePartMatcher(partName) {
`expected part ${partName} to NOT be hidden, but it is hidden` `expected part ${partName} to NOT be hidden, but it is hidden`
) )
} }
function hidePartsMatcher(...partNames) {
const hiddens = partNames.map((n) => {
if (!this._obj.config.parts[n]) {
throw new chai.AssertionError(`expected part \`${n}\` to exist in pattern`)
this.fail()
}
return this._obj.__isPartHidden(n)
})
this.assert(
hiddens.every((v) => v === true),
`expected parts [${partNames}] to be hidden, but hide check returns [${hiddens}]`,
`expected parts [${partNames}] to NOT be hidden, but hide check returns [${hiddens}]`
)
}
chai.Assertion.addMethod('hidePart', hidePartMatcher) chai.Assertion.addMethod('hidePart', hidePartMatcher)
chai.Assertion.addMethod('hideParts', hidePartsMatcher)
const blankDraft = ({ part }) => part const blankDraft = ({ part }) => part
const blankPart = (name, config = {}) => ({ const blankPart = (name, config = {}) => ({
@ -49,8 +67,7 @@ describe('Hiding parts', () => {
}) })
it("Should NOT hide the part's dependencies", () => { it("Should NOT hide the part's dependencies", () => {
expect(pattern).not.to.hidePart('fromPart') expect(pattern).not.to.hidePart('fromPart', 'afterPart')
expect(pattern).not.to.hidePart('afterPart')
}) })
describe('Inherited Parts', () => { describe('Inherited Parts', () => {
@ -75,8 +92,7 @@ describe('Hiding parts', () => {
pattern.__init() pattern.__init()
it('Should NOT hide inherited `from` dependencies', () => { it('Should NOT hide inherited `from` dependencies', () => {
expect(pattern).not.to.hidePart('fromPart') expect(pattern).not.to.hideParts('fromPart', 'mainPart')
expect(pattern).not.to.hidePart('mainPart')
}) })
it('Should NOT hide inherited `after` dependencies', () => { it('Should NOT hide inherited `after` dependencies', () => {
@ -247,13 +263,11 @@ describe('Hiding parts', () => {
}) })
it('Should hide the `after` dependencies of `from` dependencies', () => { it('Should hide the `after` dependencies of `from` dependencies', () => {
expect(pattern).to.hidePart('afterPart') expect(pattern).to.hideParts('afterPart', 'parentAfter')
expect(pattern).to.hidePart('parentAfter')
}) })
it('Should hide the `from` dependencies of `from` dependencies', () => { it('Should hide the `from` dependencies of `from` dependencies', () => {
expect(pattern).to.hidePart('fromPart') expect(pattern).to.hideParts('fromPart', 'grandParent')
expect(pattern).to.hidePart('grandParent')
}) })
}) })
@ -342,6 +356,107 @@ describe('Hiding parts', () => {
}) })
}) })
describe('HIDE_ALL', () => {
const grandParent = blankPart('grandParent')
const parent = blankPart('parent', {
from: grandParent,
})
it('Should behave like `{self: true, after: true, from: true, inherited: true}`', () => {
const main1 = blankPart('main1', {
from: parent,
after: afterPart,
hide: hidePresets.HIDE_ALL,
})
const Test = new Design({
name: 'test',
parts: [main1],
})
const pattern = new Test()
pattern.__init()
expect(pattern).to.hideParts('grandParent', 'parent', 'main1', 'afterPart')
})
it('Should work when passed as a string', () => {
const main1 = blankPart('main1', {
from: parent,
after: afterPart,
hide: 'HIDE_ALL',
})
const Test = new Design({
name: 'test',
parts: [main1],
})
const pattern = new Test()
pattern.__init()
expect(pattern).to.hideParts('grandParent', 'parent', 'main1', 'afterPart')
})
})
describe('HIDE_TREE', () => {
const grandParent = blankPart('grandParent', { from: fromPart, after: afterPart })
const parentAfter = blankPart('parentAfter')
const parent = blankPart('parent', { from: grandParent, after: parentAfter })
const mainAfterFrom = blankPart('mainAfterFrom')
const mainAfterAfter = blankPart('mainAfterAfter')
const mainAfter = blankPart('mainAfter', { after: mainAfterAfter, from: mainAfterFrom })
it('Should behave like `{from: true, inherited: true}`', () => {
const mainPart = {
name: 'mainPart',
from: parent,
after: mainAfter,
hide: hidePresets.HIDE_TREE,
draft: blankDraft,
}
const Test = new Design({
name: 'test',
parts: [mainPart],
})
const pattern = new Test()
pattern.__init()
expect(pattern).to.hideParts(
'grandParent',
'fromPart',
'afterPart',
'parentAfter',
`mainAfterFrom`,
`parent`
)
expect(pattern).to.not.hideParts('mainPart', 'mainAfter', 'mainAfterAfter')
})
it('Should work when passed as a string', () => {
const mainPart = {
name: 'mainPart',
from: parent,
after: mainAfter,
hide: 'HIDE_TREE',
draft: blankDraft,
}
const Test = new Design({
name: 'test',
parts: [mainPart],
})
const pattern = new Test()
pattern.__init()
expect(pattern).to.hideParts(
'grandParent',
'fromPart',
'afterPart',
'parentAfter',
`mainAfterFrom`,
`parent`
)
expect(pattern).to.not.hideParts('mainPart', 'mainAfter', 'mainAfterAfter')
})
})
describe('With complex inheritance', () => { describe('With complex inheritance', () => {
it('Should use the strictest hiding configuration given by toplevel parts', () => { it('Should use the strictest hiding configuration given by toplevel parts', () => {
const greatGrandParent = blankPart('greatGrandParent') const greatGrandParent = blankPart('greatGrandParent')
@ -363,9 +478,7 @@ describe('Hiding parts', () => {
const pattern = new Test() const pattern = new Test()
pattern.__init() pattern.__init()
expect(pattern).to.hidePart('parent') expect(pattern).to.hideParts('parent', 'grandParent', 'greatGrandParent')
expect(pattern).to.hidePart('grandParent')
expect(pattern).to.hidePart('greatGrandParent')
}) })
it('Should use inherited configurations that are not overridden', () => { it('Should use inherited configurations that are not overridden', () => {
const greatGrandParent = blankPart('greatGrandParent') const greatGrandParent = blankPart('greatGrandParent')